File Exchange

image thumbnail

Java Table Wrapper for User Interfaces

version 1.0.0.1 (279 KB) by

Provides the added functionality of Java tree controls for a MATLAB application

27 Downloads

Updated

View License

Please Note: If you are using R2017a or later, an improved table is included with Widgets Toolbox. https://www.mathworks.com/matlabcentral/fileexchange/66235-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.

Comments and Ratings (33)

Robyn Jackey

Robyn Jackey (view profile)

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: https://www.mathworks.com/matlabcentral/fileexchange/66235-widgets-toolbox

Chen Hong-Yu

Chen Hong-Yu

Thanks a lot for your sharing:)

Robyn Jackey

Robyn Jackey (view profile)

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?
Thanks!

Robyn Jackey

Robyn Jackey (view profile)

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

Robyn Jackey (view profile)

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

Robyn Jackey (view profile)

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

Robyn Jackey (view profile)

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.

David Martin

Robyn Jackey

Robyn Jackey (view profile)

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

Thanks, Robyn

Armindo

Hi Robyn,
Thank you for the suggestion but I already have done that (define a static path as descried below) and the problem persists. I also removed the dynamic path but matlab create it again (I dont know how). I am missing something here? If so can you give me some more detail about how to procede. Thanks in advance.
Note: I aim using the Matlab R2015b(8.6.0) 32-bit, and the Java table and Tree Controls for User Interfaces.

Static path
http://www.mathworks.com/help/matlab/matlab_external/bringing-java-classes-and-methods-into-matlab-workspace.html#f111065

Robyn Jackey

Robyn Jackey (view profile)

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.

Armindo

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 com.mathworks.consulting.swing.table.TableModel 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

Robyn Jackey (view profile)

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.

sakz

sakz (view profile)

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

Robyn Jackey (view profile)

@physicist2013 - I don't have a treetable wrapper, but you can look at Yair's entry here: http://www.mathworks.com/matlabcentral/fileexchange/42946-treetable-create-a-sortable-table-control-with-collapsible-row-groups

Very nice work !
Just a question, is there a means to combine this toolbox with the JavaTreeWrapper (https://fr.mathworks.com/matlabcentral/fileexchange/47630-tree-controls-for-user-interfaces) 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

Robyn Jackey (view profile)

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

Luke Plausin (view profile)

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

Luke Plausin (view profile)

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:
set(obj,ParamsToSet);

to :
if ~isempty(fields(ParamsToSet))
set(obj,ParamsToSet);
end

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.

Thanks!

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

Robyn Jackey (view profile)

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.

Sven

Sven (view profile)

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

Updates

1.0.0.1

Please Note: If you are using R2017a or later, an improved table is included with Widgets Toolbox. https://www.mathworks.com/matlabcentral/fileexchange/66235-widgets-toolbox

1.0.0.1

Updated license

MATLAB Release
MATLAB 8.3 (R2014a)

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video