Code covered by the BSD License  

Highlights from
GetJFrame - Retrieves a figure's underlying Java frame

4.5

4.5 | 2 ratings Rate this file 28 Downloads (last 30 days) File Size: 3.28 KB File ID: #15830

GetJFrame - Retrieves a figure's underlying Java frame

by Yair Altman

 

04 Aug 2007 (Updated 13 Oct 2011)

Enable multiple window callbacks and properties not exposed by Matlab

| 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:
blurFigure - blurs and prevents interaction on a figure window, enable/disable figure, getHWnd - retrieve the underlying Windows handle for Matlab figure(s)

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

13 Oct 2011

Fix for R2011b

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
example Lee Gunsuck 25 Feb 2011 22:05:39

Contact us at files@mathworks.com