UICOMPONENT - expands uicontrol to all Java classes

Enhanced replacement for uicontrol & javacomponent, accepting all Java (Swing/AWT) style components
12K Descargas
Actualizado 30 mar 2016

Ver licencia

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)

Citar como

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

Compatibilidad con la versión de MATLAB
Se creó con R2007a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y MATLAB Answers.

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
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