4.5

4.5 | 2 ratings Rate this file 150 downloads (last 30 days) File Size: 6.2 KB File ID: #15830

GetJFrame - Retrieves a figure's underlying Java frame

by Yair Altman

 

04 Aug 2007 (Updated 13 Aug 2007)

No BSD License  

Enable multiple window callbacks and properties not exposed by Matlab

Download Now | Watch this File

File Information
Description

Syntax:
  jframe = getjframe(hFig)

Description:
GETJFRAME retrieves the current figure (gcf)'s underlying Java frame, thus enabling access to all 35 figure callbacks that are not exposed by Matlab's figure.

Notable callbacks include: FocusGainedCallback, FocusLostCallback, KeyPressedCallback, KeyReleasedCallback, MouseEnteredCallback, MouseExitedCallback, MousePressedCallback, MouseReleasedCallback, WindowActivatedCallback, WindowClosedCallback, WindowClosingCallback, WindowOpenedCallback, WindowStateChangedCallback and 22 others.

The returned jframe object also allows access to other useful window features: 'AlwaysOnTop', 'CloseOnEscapeEnabled', 'Resizable', 'Enabled', 'HWnd' (for those interested in Windows integration) etc. Type "get(jframe)" to see the full list of properties.

GETJFRAME(hFig) retrieves a specific figure's underlying Java frame. hFig is a Matlab handle, or a list of handles (not necesarily figure handle(s) - the handles' containing figure is used).

Examples:
get(getjframe,'ListOfCallbacks'); %display list of supported callbacks
set(getjframe,'WindowStateChangedCallback','disp(''Window min/maxed'')')
set(getjframe,'WindowDeiconifiedCallback',@winMaximizedCallback)
set(getjframe,'WindowIconifiedCallback',{@winMinimizedCallback,mydata})
set(getjframe,'CloseOnEscapeEnabled','on')
jframes = getjframe([gcf,hButton]); % get 2 java frames, from 2 figures

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
FindJObj - find java handles of Matlab graphic objects
This submission has inspired the following:
getHWnd - retrieve the underlying Windows handle for Matlab figure(s), enable/disable figure

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Java should be enabled (which it is normally)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
10 Nov 2007 Bob W

Nice utility.

25 Jan 2008 Vihang Patil

Great!!

Please login to add a comment or rating.
Updates
08 Aug 2007

wrong file was initially uploaded by mistake - now fixed

13 Aug 2007

Added Matlab figure handle property; improved responsiveness handling; added support for array of handles; added sanity checks for illegal handles

Tag Activity for this File
Tag Applied By Date/Time
gui tools Yair Altman 22 Oct 2008 09:22:02
example Yair Altman 22 Oct 2008 09:22:02
figure window callback java Yair Altman 22 Oct 2008 09:22:02
example Holger Ulmer 14 Oct 2009 10:59:39
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com