File Exchange

image thumbnail

Java Table Wrapper for User Interfaces

version (279 KB) by Robyn Jackey
Provides the added functionality of Java tree controls for a MATLAB application


Updated 16 Apr 2018

View License

Please Note: If you are using R2017a or later, an improved table is included with Widgets Toolbox.
This package provides the capability to easily create Java-based table controls for a MATLAB application or user interface using a simple MATLAB® object-oriented interface. This package includes and wraps the Java® code necessary to implement a Java® JTable, enabling you to create the tree by writing only MATLAB® code, for a set of included features. This is useful for situations where you need to overcome a limitation in MATLAB’s uitable.

Cite As

Robyn Jackey (2020). Java Table Wrapper for User Interfaces (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (33)

Vyshakh Pv

How to programmatically Highlight a Cell or Row in the Table?
(If the row to be selected is out of the visible area, table should automatically scroll)

Robyn Jackey

If you are using R2017a or later, please try out my new entry "Widgets Toolbox", and please provide feedback on it. The toolbox incorporates an improved version of the Java Table and Java Tree wrappers along with a number of additional components.

Please see:

Thanks a lot for your sharing:)

Robyn Jackey

Brent - I was unaware of this. Can you contact me directly? (click on my name above, and contact author)

This Java wrapper only runs smoothly on Windows because of the .jar file. Is there any method to recompile the wrapper for Linux distributions?

Robyn Jackey

Hi Saket, it should be possible. There is a place where I set a bunch of mouse callbacks such as MouseClickedCallback. There's other callbacks on the java objects you can use called 'KeyPressedCallback', 'KeyReleasedCallback', 'KeyTypedCallback'.

saket kumar

Hi Robyn, Is there any way to implement "KeyPressFcn" ?

Steve Page

Thanks Robyn I appreciate your feedback. I now use this instead of uitable in all my development work, it gives a much better user experience.

Robyn Jackey

Hi Steve,

You're right, it is not working. There are several column width fields in the JTable and I am not certain of the relationships between them. However, this alternative seems to do what you're looking for:
t.ColumnResizePolicy = 'off'
t.ColumnPreferredWidth(:) = 30

Steve Page

Hello Robyn - generally a good submission and fixes some annoying limitations with uitable. However the ColumnWidth property does not seem to have any effect - the width of the columns remains evenly distributed across the width of the table whatever the settings of ColumnWidth. I got the same result when I added ColumnWidth property to Example3 as I got in my application. I could see no reference to this being a known issue in the documentation. I am using R2016b. Any ideas?

Robyn Jackey

Thank you Roman! I will add this to my list of future fixes to make.

I hope to find time to provide an update for a number of small items, but it will likely not be until at least early 2017.

I found a fix for my problem with the meta key on Mac platform. Because pressing the CMD key and right-clicking both result in isMetaDown being true, I changed line 1612 in Table.m like this:

% Which button was clicked?
if e.getButton() == 3 % <-NEW | OLD -> "e.isMetaDown"
% Right-click

This works for me. Maybe it will work on Windows as well.

The construction is really clear but the main default is the absence of documentation. The examples given with the tool are really poor compared to the possibilities offered by the tool. Moreover, the inputs and outputs waited for the differents methods of the Table object are not described so I had to search the exact working in the code in order to understand the complete working.

Robyn Jackey

Hi Roman, I have not encountered this as I'm not a mac user. The mouse clicks for the table are handled in Java and I am not sure what limitations there may be. If you breakpoint in the onMouseClick method of Table.m, you could do a get(e) to see what eventdata is generated for each combination on Mac. If it's different than for PC we could probably handle it with an "if ismac" statement.

Feel free to email me directly via contact author.

Hey Robyn,
i'm having problems with modifier keys on the Mac platform.
We use the CMD-key instead of the Ctrl-key when adding a cell to the selection.
Unfortunately the event in onMouseClicked reports a MetaDown situation when holding the CMD-key while clicking. That gets interpreted as a right-click. It does the same for an actual right-click aswell. They're indistinguishable.
Is there any way of changing the modifier that gets reported when the Cmd-key is pressed? It should say ControlDown.

Robyn Jackey

Armindo, can you contact me directly by clicking on my name and sending me a note.

Thanks, Robyn

Robyn Jackey

Hi Armindo, it will probably resolve it if you add the Java files to your static Java path in MATLAB. This submission automatically attempts to add the path needed to the dynamic Java class path, but the dynamic path can have issues like this. After doing so, you may need to remove the code that adds the dynamic path to avoid warnings about adding a dynamic path that's already on the static paths list.


Hi Robyn,

Nice submission, I have been using it. However time to time matlab generate an error and close and after that (when I open again matlab) I get this error:

Error using javaObjectEDT
No class can be located on the Java class path

Even after uninstal and install again the toobox I get this error. How can I solve this?

Robyn Jackey

Hi sakz, I don't think it's possible in the current implementation to have an editable popup column. It would probably need modification to the Java code. It also only supports column formatting in the current state.


Very nice submission..!
Is there any way to switch between editable/non-editable 'popup' and 'popupcheckbox' ? In the given examples "popup" are non-editable , i.e. you can't type in it and 'popupcheckbox' are editable.

Do you have any updated version in which we can format each cell separately ?

Thanks Robin, I had a look at Yair's entry. It is not at all easy to use, and looks like unfinished work. I will try anyway.

Robyn Jackey

@physicist2013 - I don't have a treetable wrapper, but you can look at Yair's entry here:

Very nice work !
Just a question, is there a means to combine this toolbox with the JavaTreeWrapper ( that you also proposed, to realise a tree table ? This would be reaaly awesome. If yes would you mind provide a small example ?
Thanks a lot.

Robyn Jackey

Hi Luke, thanks for your feedback. I will look into fixing the errors when I have time, but it looks like you have a workaround for now. I agree the requested features would be useful adds.

Luke Plausin

If I was allowed to write a wishlist of new features/fixes, it would be these:

Sortable columns

Checkboxes on columns/rows

Enable guidata(hTable) on the callback functions

Proportional resizing of columns - like in GUI layout toolbox, where you can set obj.Sizes = [20 30 -1 -4]

For some reason there is a bug where I can't plot to gca inside a jTable event - instead plot opens a new figure

Keep up the good work!

Luke Plausin

Fantastic effort. Needs a little work but this is already very useful.

Examples 1 and 3 threw errors.

I got example 3 working by changing line 465 of Table.m from:

to :
if ~isempty(fields(ParamsToSet))

I am getting an error on Example 1:
Getting the 'JTable' property of the 'uiextras.jTable.Table' class is not allowed.

I am guessing this is because it is private - as sam pointed out.


md nahid

is there a way to reorder the nodes?
I tried the insertNode, but it creates an empty space in the place of node that needs to move.
any help is appreciated.

Robyn Jackey

Thank you David and Sven for your feedback! I agree with all your comments.

David Barry

Once again, fantastic submission Robyn. I agree with Sven, 5/5 for intention but as always, there is more to do. I hope your colleagues in development are taking note of this excellent piece of work!

Things I would like to see:
1) Sortable and filterable column headers similar to com.jidesoft.grid.SortableTable and com.jidesoft.grid.AutoFilterTableHeader

2) Ability to specify formatting of individual cells from MATLAB. Specifically I would like to be able to set the cell foreground and background colours and fonts. Your bank column renderer is a step towards this with the red foreground for negative numbers but I wan't the decision logic to lie in MATLAB not in the Java renderer.


5 stars not yet for functionality but for intention. The native tables are underdone and this object oriented approach with clear documentation is much appreciated.

Just a note - Example1 tries to access the JTable property (which is protected). It's useful for developers to have the underlying jtable property available (but maybe hidden, if you want to simplify the interface as much as possible for users).


Please Note: If you are using R2017a or later, an improved table is included with Widgets Toolbox.

Updated license

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux