No BSD License  

Highlights from
UICOMPONENT - expands uicontrol to all Java classes


5.0 | 19 ratings Rate this file 43 Downloads (last 30 days) File Size: 33.3 KB File ID: #14583
image thumbnail

UICOMPONENT - expands uicontrol to all Java classes



10 Apr 2007 (Updated )

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

| Watch this File

File Information

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

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.

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)


This file inspired Password Entry Dialog, Spinner Demo, Control Google Earth Milktruck From Matlab, Using Java Swing Components In Matlab, Statusbar, Ui Split Pane Split A Container (Figure/Frame/Uipanel) Into Two Resizable Sub Containers, and Selectcolor.M.

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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (25)
10 Feb 2014 Amihay Blau

A simple and amazing way to updgrade the UI.

Thank you

10 Feb 2014 Amihay Blau

A simple and amazing way to updgrade the UI.

Thank yoy

31 Jan 2014 Pooya89  
20 Nov 2013 Caleb

Okay, I figured out the filter and the 'Open' and 'Cancel' buttons, but still can't figure out the icons.

20 Nov 2013 Caleb

Thank you so much for this submission; I'm finding that it's very powerful and well thought out. I was wondering if someone could help me, though. I'm trying to create my own file chooser so that I'm able to add some check boxes to it. I've got that part down, but I'm not sure how to correctly create my own file filter, add callbacks to the 'Open' and 'Cancel' push buttons, and add icons to the buttons to the right of the directory selection drop down menu. I've tried setting the 'ActionPerformedCallback' property, but for some reason the callback function is only called when I click the 'Cancel' button.

08 May 2013 Peter  
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.

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!)

24 Jun 2011 Isaac  
23 Jun 2011 B_Richardson

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

25 May 2010 Chris Rodgers

Great idea!

08 May 2010 shrey sinha  
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!

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.

01 Apr 2009 Jveer

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

30 Mar 2009 Jveer  
30 Mar 2009 Jveer

the best gui related submission yet

04 Dec 2007 Jax Cao

Useful tool

22 Sep 2007 Qun Han


18 Sep 2007 Dawn Song

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

18 Sep 2007 Dawn Song

Great TOOl ?

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!

27 Jun 2007 Malcolm Lidierth

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

22 May 2007 Arwel Hughes

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

11 Apr 2007 Matthew Whitaker

This is really fascinating. Note your example 1 and 2 should read:

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.

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

Contact us