findjobj - find java handles of Matlab graphic objects

버전 (183 KB) 작성자: Yair Altman
Find java objects contained within a specified java container or Matlab GUI handle
다운로드 수: 47.8K
업데이트 날짜: 2021/8/17

라이선스 보기

Find all java objects contained within a java container or Matlab GUI handle
If no output parameter is specified, then an interactive GUI window will be displayed with a tree-view of all container components, their properties and callbacks.
[handles,levels,parentIds,listing] = findjobj(container,'PropName',PropValue(s),...)
- container - optional GUI handle. If unsupplied then current figure will be used
- 'PropName',PropValue - optional list of case insensitive property pairs. PropName may also be named -PropName.
Supported properties:
- 'position' - filter results based on those elements that contain the specified X,Y position or a java element
Note: specify a Matlab position (X,Y = pixels from bottom left corner), not a java one
- 'size' - filter results based on those elements that have the specified W,H (in pixels)
- 'class' - filter results based on those elements that contain the substring (or java class) PropValue
Note: filtering is case insensitive and relies on regexp, so you can pass wildcards etc.
- 'property' - filter results based on elements that possess the specified case-insensitive property string or have property values in cell array format: {'propName', 'propValue'}. Example: findjobj(...,'property', {'Text','click me'})
- 'depth' - filter results based on specified depth. 0=top-level, Inf=all levels (default=Inf)
- 'flat' - same as: 'depth',0
- 'not' - negates the following filter: 'not','class','c' returns all elements EXCEPT those with class 'c'
- 'persist' - persist figure components information, allowing much faster results for subsequent invocations
- 'print' - display all java elements in a hierarchical list
Note1: optional PropValue of element index or handle to java container
Note2: normally this option would be placed last, after all filtering is complete.
- 'list' - same as 'print'
- handles - list of handles to java elements
- levels - list of corresponding hierarchy level of the java elements (top=0)
- parentIds - list of indexes (in unfiltered handles) of the parent container of the corresponding java element
- listing - results of 'print'/'list' options (empty if 'print'/'list' were unspecified)
Sample usage:
>> hButton = uicontrol('string','click me');
>> jButton = findjobj(hButton,'nomenu'); % or: jButton = findjobj('property',{'Text','click me'});
>> jButton.setFlyOverAppearance(1);
>> jButton.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR));
>> set(jButton,'FocusGainedCallback',@myMatlabFunction); % some 30 callback points available...
>> jButton.get; % list all changeable properties...
>> hEditbox = uicontrol('style',edit');
>> jEditbox = findjobj(hEditbox,'nomenu');
>> jEditbox.setCaretColor(;
>> jEditbox.KeyTypedCallback = @myCallbackFunc; % many more callbacks where this came from...
>> jEdit.requestFocus;
(Many more examples in the utility's help section)
Known issues/limitations:
- Cannot currently process multiple container objects - just one at a time
- Initial processing is a bit slow when the figure is laden with many UI components (so better use 'persist')
- Passing a container Matlab handle is currently found by position+size: should find a better way to do this
- Labels have a write-only text property in java, so can't be found using 'property',{'Text','string'} notation
Technical description:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!
Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)
See also:
java, handle, findobj, findall

인용 양식

Yair Altman (2024). findjobj - find java handles of Matlab graphic objects (, MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R14SP3
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
Help CenterMATLAB Answers에서 Graphics Objects에 대해 자세히 알아보기

받음: UIINSPECT - display methods, properties & callbacks of an object

줌: inspect time series events, BacStalk, BiofilmQ, tweak, kristinbranson/JAABA, MATLAB Snippets, Stock Trader Journal, directorscut82/matbuttons, Microscopy Image Browser (MIB), attachScrollPanelTo - add scroll-panel to a uipanel or axes, Microscopy Image Browser 2 (MIB2), statusbar, getjframe - Retrieves a figure's underlying Java frame, enable/disable entire figure window, setDesktopVisibility, UIINSPECT - display methods, properties & callbacks of an object, Manage and Dock Figures into Group, Virtual Tackball, maximize, uhelp, Command window text, Graphical Wrappers, Reorderable Listbox, Colorize Document Bar, tortoise svn toolbar integration,, Realtime trading with Matlab and IB presentation files, fixuilabels, Programmatically scroll Variables Editor, embeddedmethodsviewer - show functions and methods within matlab editor, Figure from text file (supports HTML tags), Panic Simulator, tprintf -- Print to Second Terminal Window, GavriYashar/Matlab-Editor-Plugin, Copy Paste, Probability Distribution Plotter, Dynamic Search Box, checkVersion - Check for a newer file version on the File Exchange, figs2tabs - move figures into a single tabbed gui, Dicom Operator - EsmeProcess, Chess Master, smart_scrollbars fixes Matlab's listbox/editbox scrollbars to only show as needed, Message Logger, scatool, SessionManager, kview - Interface for signal/data easy visualization and processing, uicontrolHyperLink

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보

Updated findjobj_fast: support for desktop & figure handles, hide JavaFrame deprecation warning, improved warning handling (thanks T. Carpenter)

Fix for changed warning IDs in R2019b; removed javacomponent warning; added promo message

Additional fix for R2018b; added separate findjobj_fast utility

Fix for R2018b suggested by Eddie (FEX); speedup suggested by Martin Lehmann (FEX); alert if trying to use with uifigure

Fixed two edge-cases (one suggested by H. Koch)

Fixed edge-cases in old Matlab release; slightly improved performance even further

Improved performance for the most common use-case (single input/output): improved code + allow inspecting groot

Significantly improved performance for the most common use-case (single input/output)

Fixed case of docked figure

Differentiate between overlapping controls (for example in different tabs)

Additional fixes for R2014a, R2014b

Fixes for R2014b

Minor fix for R2014a; handled case of invisible figure container; only check for newer FEX version in non-deployed mode and only once every 12 hours

Additional fixes for the upcoming HG2

Fix for the upcoming HG2; fixed HG-Java warnings

Fixed callbacks table grouping & editing bugs; added hidden properties to the properties tooltip; updated help section

Improved callbacks table; improved export to workspace; fixed tree refresh failure; fixed: tree node-selection didn't update the props pane nor flash the selected component

Fixes for R2012a as well as some older Matlab releases

Fixed 'File is empty' messages in compiled apps

Fix suggested by Ward; fixes for R2011a and R2010b; fixed download (m-file => zip-file)

Minor fix to support combo-boxes (aka drop-down, popup-menu) on Windows

Important release: Fixes for R2010a, debug listing, objects not found, component containers that should be ignored etc.

Forced an EDT redraw before processing; warned if requested handle is invisible

Fix to display text labels deep in HG hierarchy

Fixed uitreenode warning; found a way to display label text next to the relevant node name

Fixed auto-collapse of invisible container nodes; added dynamic tree tooltips & context-menu; minor fix to version-check display

Fix for Matlab 7.0 as suggested by Oliver W; minor GUI fix (classname font); fixed edge-case of missing JIDE tables

Added support for future Matlab versions that will not support JavaFrame; added sanity checks for axes items; added 'debug' input arg; increased size tolerance 1px => 2px

Fixed location of popupmenus (always 20px high despite what's reported by Matlab...); fixed uiinspect processing issues; added blog link; narrower action buttons; automatic 'nomenu' for uicontrol inputs; significant performance improvement

Fixed position of some Java components; fixed properties tooltip; fixed node visibility indication

Indicated components visibility (& auto-collapse non-visible containers); auto-highlight selected component; fixed node icons, figure title & tree refresh; improved error handling; displayed FindJObj version update description if available

Fixed update check; added dedicated labels icon; fixed description

Fixed compatibility problems with previous Matlab versions; updated screenshot

Callbacks table fixes; better object inspection; fix update check according to new FEX website; R2008b compatibility; fixed minor bug as per Johnny Smith's comment

Fixed edge case problem with class properties tooltip; used existing object icon if available; added checkbox option to hide standard callbacks