UICOMPONENT - expands uicontrol to all Java classes

版本 1.8.0.0 (59.6 KB) 作者: Yair Altman
Enhanced replacement for uicontrol & javacomponent, accepting all Java (Swing/AWT) style components
12.0K 次下载
更新时间 2016/3/30

查看许可证

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 版本兼容性
创建方式 R2007a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Migrate GUIDE Apps 的更多信息

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