Code covered by the BSD License  

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

4.66667

4.7 | 3 ratings Rate this file 33 Downloads (last 30 days) File Size: 6.69 KB File ID: #15830

GetJFrame - Retrieves a figure's underlying Java frame

by

 

04 Aug 2007 (Updated )

Enable multiple window callbacks and properties not exposed by Matlab

| Watch this File

File Information
Description

Syntax:
  jframe = getjframe(hFigOrComponent)
 
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 necessarily 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)
 
Warning:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!

Acknowledgements

Find J Obj Find Java Handles Of Matlab Graphic Objects inspired this file.

This file inspired Set Fig Transparency Set Figure Transparency / Fading, Tactics Toolbox, Blur Figure Blurs And Prevents Interaction On A Figure Window, Enable/Disable Figure, and Get H Wnd 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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
24 Sep 2014 Jason Nicholson

Great work. Thank you for keeping this up to date.

This is very useful. I am using it to control minimizing and maximizing the figure windows. I know the potential is much greater.

25 Jan 2008 Vihang Patil

Great!!

10 Nov 2007 Bob W

Nice utility.

Updates
08 Aug 2007

wrong file was initially uploaded by mistake - now fixed

13 Oct 2011

Fix for R2011b

02 Sep 2014

Fix for R2014b (HG2)

Contact us