getjframe - Retrieves a figure's underlying Java frame

バージョン 1.6.0.0 (3.53 KB) 作成者: Yair Altman
Enable multiple window callbacks and properties not exposed by Matlab
ダウンロード: 4.9K
更新 2019/3/1

ライセンスの表示

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).

Usage 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!

引用

Yair Altman (2024). getjframe - Retrieves a figure's underlying Java frame (https://www.mathworks.com/matlabcentral/fileexchange/15830-getjframe-retrieves-a-figure-s-underlying-java-frame), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2007a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.6.0.0

Extra check for additional robustness

1.5.0.0

Additional fixes for R2014b onward (HG2)

1.2.0.0

Fix for R2014b (HG2)

1.1.0.0

Fix for R2011b

1.0.0.0

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