No BSD License  

Highlights from
UICOMPONENT - expands uicontrol to all Java classes

5.0

5.0 | 14 ratings Rate this file 72 Downloads (last 30 days) File Size: 33.31 KB File ID: #14583
image thumbnail

UICOMPONENT - expands uicontrol to all Java classes

by Yair Altman

 

10 Apr 2007 (Updated 20 Jul 2007)

Enhanced replacement for uicontrol & javacomponent, accepting all Java (Swing/AWT) style components

| Watch this File

File Information
Description

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

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!

Change log:
See the bottom of this page

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

Acknowledgements
This submission has inspired the following:
passwordEntryDialog, UISplitPane - Split a container (figure/frame/uipanel) into two resizable sub-containers, SpinnerDemo, Control Google Earth Milktruck from Matlab, Using Java Swing components in MATLAB, statusbar
MATLAB release MATLAB 7.4 (R2007a)
Other requirements Java should be enabled (duh!) Should work on Matlab 7+, but might work on earlier versions too. Does NOT work on Matlab 6.5
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (19)
11 Apr 2007 Matthew Whitaker

This is really fascinating. Note your example 1 and 2 should read:
uicomponent('Style','edit','String','hello');

and
uicomponent('Parent', fig2, 'Style', 'edit','String','hello');

instead of 'uicontrol'

I have not found any obvious issues although with the extensive use of non-documented features I'll have to test more extensively but this is a really nice wrapper for uicontrol and javacomponent. A lot of goodies in the code for anyone interested in incorporating Swing components into their interfaces.

22 May 2007 Arwel Hughes

This is an excellent tool. It works very well with a number of components I've tried.

27 Jun 2007 Malcolm Lidierth

Excellent. Produces great GUIs that work on both Windows and Mac without needing tweaking for each platform.

19 Jul 2007 Heiko Marx

After changing line 256 from strcmpi to strncmpi, because I use 'Visible' instead of 'vis', this excellent tool has made it to my daily use. Thank you very much!

18 Sep 2007 Dawn Song

Great TOOl ?

18 Sep 2007 Dawn Song

Oh, sorry, I mistyped, I meaned ! not ?

22 Sep 2007 Qun Han

Great!

04 Dec 2007 Jax Cao

Useful tool

30 Mar 2009 Jveer

the best gui related submission yet

30 Mar 2009 Jveer  
01 Apr 2009 Jveer

can these components be made transparent for e.g overlaying a transparent ticklabeled slider over a colorbar?

03 Apr 2009 Hans

Thanks for sharing this code with us, Yair. Whenever I need a java thingy that is not available in MATLAB, I use uicomponent.

27 Dec 2009 Evgeny Pr

It is fine!
I knew that in Matlab it is possible to do such, but you have made it very well! Thanks!

08 May 2010 shrey sinha  
25 May 2010 Chris Rodgers

Great idea!

23 Jun 2011 B_Richardson

Can someone explain to a novice GUI builder the significance of this download?

24 Jun 2011 Isaac  
24 Jun 2011 Isaac

It may not be obvious to the novice, but one experienced builder appreciates having access to all the "stuff" in a uniform interface. YMMV. (Thanks, Yair!)

28 Jun 2011 Gaurav Gupta

Awesome job, but can u please tell me why uicontrol objects not hide when their position is out of parent uipanel area.

Please login to add a comment or rating.
Updates
12 Apr 2007

Set large initial size for *Chooser classes; fixed Window subclasses issue; fixed help comment; enabled non-figure parent; enabled non-cell ctorArgs; set default Tag prop

18 May 2007

Handle pre-existing Java components

20 Jul 2007

Handle shortened property names per suggestion by H. Marx

Tag Activity for this File
Tag Applied By Date/Time
data exploration Yair Altman 22 Oct 2008 09:08:23
uicontrol Yair Altman 22 Oct 2008 09:08:23
javacomponent Yair Altman 22 Oct 2008 09:08:24
java Yair Altman 22 Oct 2008 09:08:24
graphics Yair Altman 22 Oct 2008 09:08:24
javacomponent li hoo 10 Nov 2008 18:13:49
uicontrol Sherif Elnabarawy 19 Apr 2010 07:49:18
javacomponent Etienne 06 May 2010 09:34:18
graphics CHEN CHEN 09 Oct 2010 08:46:25
javacomponent Joseph Jay 23 May 2011 05:02:28

Contact us at files@mathworks.com