Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Java handle to R2008a uitable

Subject: Java handle to R2008a uitable

From: Jesse Lai

Date: 9 Aug, 2008 12:51:02

Message: 1 of 5

Does anyone know how to get the java handle to the new
R2008a uitable? There are several properties that I need to
access that can only be done with setting the Java properties.

Subject: Java handle to R2008a uitable

From: Donn Shull

Date: 9 Aug, 2008 16:34:02

Message: 2 of 5

"Jesse Lai" <jlai.DELETETHISmatlab@gmailNOSPAM.moc> wrote
in message <g7k3rm$b1n$1@fred.mathworks.com>...
> Does anyone know how to get the java handle to the new
> R2008a uitable? There are several properties that I need
to
> access that can only be done with setting the Java
properties.

If your tables handle graphics handle is t, then:

jt = java(handle(t));

will return an object of class uitableBeanAdapter0 which
may allow you access to the things you want.

Donn

Subject: Java handle to R2008a uitable

From: Jesse Lai

Date: 9 Aug, 2008 20:16:44

Message: 3 of 5

Donn Shull wrote:
>
> If your tables handle graphics handle is t, then:
>
> jt = java(handle(t));
>
> will return an object of class uitableBeanAdapter0 which
> may allow you access to the things you want.
>
> Donn
>

Donn,

I did try that, but it doesn't give the handle to the actual java table.
  It gives a java handle to the MATLAB wrapper or something. I want to
be able to access the methods of the java table directly, such as
getSelectedRows/getSelectedColumns and also be able to set them since
the MATLAB uitable doesn't have any capability to set the active cell.
A major oversight IMHO.

I'm able to do it using Yair Altman's findjobj for uitables that are
made with the uitable command, such as:

hFig = figure;
h = uitable('Parent', hFig, 'Position', [0 0 100 100]);
t = findjobj(h);
t1 = get(t,'ViewPort');
jt = get(t1, 'View');

They have the table buried inside of Java scroll frames, etc.

But when I try the same code on the GUIDE uitable, it doesn't work. The
findjobj function returns a null handle.

I'll keep playing, please keep suggestions coming.

Thanks,

Jesse

Subject: Java handle to R2008a uitable

From: Yair Altman

Date: 10 Aug, 2008 07:19:06

Message: 4 of 5

Jesse Lai <"jlai.[DELETETHIS]matlab"@gmail[NOSPAM].moc>
wrote in message
> hFig = figure;
> h = uitable('Parent', hFig, 'Position', [0 0 100 100]);
> t = findjobj(h);
>
> But when I try the same code on the GUIDE uitable, it
> doesn't work. The findjobj function returns a null handle.


Try running findjobj on hFig (not h), without any output:
findjobj(hFig,'-nomenu');

- this will display a GUI window with ALL the object in your
figure, and I bet you can find the JTable buried somewhere
in there. Once you find it, you can use its classname or
other property to provide as extra params to findjobj, in
order to get the relevant handle programmatically.

Let us know what you find.

Yair Altman

Subject: Java handle to R2008a uitable

From: Jesse Lai

Date: 10 Aug, 2008 14:50:04

Message: 5 of 5

Yair Altman wrote:
> Try running findjobj on hFig (not h), without any output:
> findjobj(hFig,'-nomenu');
>
> - this will display a GUI window with ALL the object in your
> figure, and I bet you can find the JTable buried somewhere
> in there. Once you find it, you can use its classname or
> other property to provide as extra params to findjobj, in
> order to get the relevant handle programmatically.
>
> Let us know what you find.
>
> Yair Altman

Yair,

I think I've found the difference, although I haven't looked deeply in
your code to see the difference. First, I did try your suggestion of
searching the handle of the GUI. In case someone's interested, this
seemed to work AFTER the GUI was made visible:

jt = findjobj(hFig, '-nomenu', 'class', 'uitablepeer');

where hFig is the handle the GUI figure. But you can also use the more
direct approach of just passing in the handle to the uitable at that
point and using the code I posted previously to get the viewport.

The problem I'm running into is that I am putting that line in the
opening function of the GUIDE gui. At the end of the OpeningFcn, the
GUI visibility is set to off. Well, findjobj doesn't return any results
if the figure visibility is off. As soon as I turn it on, it works as
expected.

I'm not sure that I'm going to be able to use the uitable anyway because
of its many limitations. I'm going to keep playing with it though. Not
sure where to put this function though if it doesn't work in OpeningFcn.

On a side note, your findjobj function gives lots of warnings in R2008a
about the javaframe property. There's not much you can do about it I
suppose unless the user suppress these warnings, which is what I do for
my code. But in R2008b, it gets lots more warnings and exceptions,
although it does make it through eventually. The uitreenode is being
added to a future release, so they've added a '-v0' switch in R2008b
like they did for the uitable. Also, your jidesoft table causes some
java exceptions with the built-in uitable because they're using it too
for the column headers or something.

Jesse

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us