UICOMPONENT - expands uicontrol to all Java classes
UICOMPONENT is intended as a direct replacement of Matlab's built-in UICONTROL and JAVACOMPONENT functions. It accepts all parameters and styles that UICONTROL accepts, as well as any other displayable Java (Swing/AWT) component class. The calling convention and syntax of UICONTROL were preserved for full backwards compatibility.
UICOMPONENT uses the built-in UICONTROL whenever possible (i.e, for all the standard styles), and uses JAVACOMPONENT to create and display all the other java classes. UICOMPONENT supports the entire Swing/AWT and any user-defined classes, in several equivalent case-insensitive formats. For example, 'Spinner', 'spiNNer', 'JSpinner' and 'javax.swing.jspinner' are all equivalent and recognized.
Notable new styles that are now available (unavailable in built-in UICONTROL): spinner, slider, editable comboBox, passwordField, tree, table, fileChooser, colorChooser, progressBar, applet. But there are so many more - whatever is available in Java is now seamlessly available in your Matlab GUI.
Examples (more examples in attached screenshot & in the help comment):
- uicomponent('style','jspinner','value',7); % simple spinner with initial value
- uicomponent('style','javax.swing.jslider','tag','myObj'); % simple horizontal slider
- uicomponent('style','JComboBox',{1,pi,'text'},'editable',true); % editable drop-down
The screenshot can be recreated using the createScreenshot script that is included in this submission. It is provided to illustrate the use of UICOMPONENT for various different components.
Callbacks:
Over 30 callback hooks are exposed to the user for all components (the exact list depends on the specific java component used). These callbacks include mouse movement/clicks, keyboard events, focus gain/loss, data changes etc.
Warning:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!
Technical description:
http://undocumentedmatlab.com/blog/javacomponent
Change log:
See the bottom of this page
Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)
引用格式
Yair Altman (2024). UICOMPONENT - expands uicontrol to all Java classes (https://www.mathworks.com/matlabcentral/fileexchange/14583-uicomponent-expands-uicontrol-to-all-java-classes), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
致谢
启发作品: BiofilmQ, tweak, Drag & Drop functionality for JAVA GUI components, attachScrollPanelTo - add scroll-panel to a uipanel or axes, statusbar, Using Java Swing components in MATLAB, passwordEntryDialog, UISplitPane - Split a container (figure/frame/uipanel) into two resizable sub-containers, SpinnerDemo, Control Google Earth Milktruck from Matlab, selectcolor.m, scatool
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.8.0.0 | Added support for all HG2 containers (inc. uiextras) as parents, per suggestion by D. Sampson |
||
1.7.0.0 | Added missing Java files to the zip file; clarified about the createScreenshot script in main description text. |
||
1.6.0.0 | Added tabs and panels as acceptable parent containers per suggestion by Amir G. |
||
1.2.0.0 | Fixed a bug in setting the JavaComponent field |
||
1.1.0.0 | Fixed for R2014b (HG2) |
||
1.0.0.0 | Handle shortened property names per suggestion by H. Marx |