From: Bass on
Thanks again Yair!
This is a nice piece of code, but doesn't quite work for the new version of uitable.

the new call (probably after 2008a? I am using 2010a) returns a numeric handle
mtable = uitable('Parent',gcf,);

I can use your findjobj to get the java object,
it is:
javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane

I guess a UIScrollPane?
which doesn't have a .getTable method.
Any idea how to get the selectedRows and Columns from this?

cheers



"Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <fqrd8l$30$1(a)fred.mathworks.com>...
> > Is there a way to tell what cells are currently selected?
>
> mtable = uitable(gcf, magic(3), {'A', 'B', 'C'});
> jtable = mtable.getTable;
> row = jtable.getSelectedRow + 1; % Java indexes start at 0
> col = jtable.getSelectedColumn + 1;
>
> If multiple cells are selected, you might want to use
> getSelectedRows and getSelectedColumns which return an array
> of int32 indexes (0-based).
>
> Yair
From: Bass on
Answer my own question....

Here is the solution for the new (after 2008a??) uitable which is actually a java UIScrollPane.

mtable = uitable('Parent',gcf,);

jUIScrollPane = findjobj(mtable);
jUITable = jUIScrollPane.getViewport.getView;

row = jUITable.getSelectedRow + 1; % Java indexes start at 0
col = jUITable.getSelectedColumn + 1;



"Bass " <bassam.atallah(a)gmail.com> wrote in message <i135jk$oci$1(a)fred.mathworks.com>...
> Thanks again Yair!
> This is a nice piece of code, but doesn't quite work for the new version of uitable.
>
> the new call (probably after 2008a? I am using 2010a) returns a numeric handle
> mtable = uitable('Parent',gcf,);
>
> I can use your findjobj to get the java object,
> it is:
> javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane
>
> I guess a UIScrollPane?
> which doesn't have a .getTable method.
> Any idea how to get the selectedRows and Columns from this?
>
> cheers
>
>
>
> "Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <fqrd8l$30$1(a)fred.mathworks.com>...
> > > Is there a way to tell what cells are currently selected?
> >
> > mtable = uitable(gcf, magic(3), {'A', 'B', 'C'});
> > jtable = mtable.getTable;
> > row = jtable.getSelectedRow + 1; % Java indexes start at 0
> > col = jtable.getSelectedColumn + 1;
> >
> > If multiple cells are selected, you might want to use
> > getSelectedRows and getSelectedColumns which return an array
> > of int32 indexes (0-based).
> >
> > Yair
From: Adi on
hi, i've just read ur post above. i'm using MATLAB R2009a

i've tried ur suggested solution, but MATLAB returns an error message after i type in:

>>jUITable = jUIScrollPane.getViewport.getView;

Attempt to reference field of non-structure array

have i missed any step?

thanks!

"Bass " <bassam.atallah(a)gmail.com> wrote in message <i136c3$c9u$1(a)fred.mathworks.com>...
> Answer my own question....
>
> Here is the solution for the new (after 2008a??) uitable which is actually a java UIScrollPane.
>
> mtable = uitable('Parent',gcf,);
>
> jUIScrollPane = findjobj(mtable);
> jUITable = jUIScrollPane.getViewport.getView;
>
> row = jUITable.getSelectedRow + 1; % Java indexes start at 0
> col = jUITable.getSelectedColumn + 1;
>
>
>
> "Bass " <bassam.atallah(a)gmail.com> wrote in message <i135jk$oci$1(a)fred.mathworks.com>...
> > Thanks again Yair!
> > This is a nice piece of code, but doesn't quite work for the new version of uitable.
> >
> > the new call (probably after 2008a? I am using 2010a) returns a numeric handle
> > mtable = uitable('Parent',gcf,);
> >
> > I can use your findjobj to get the java object,
> > it is:
> > javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane
> >
> > I guess a UIScrollPane?
> > which doesn't have a .getTable method.
> > Any idea how to get the selectedRows and Columns from this?
> >
> > cheers
> >
> >
> >
> > "Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <fqrd8l$30$1(a)fred.mathworks.com>...
> > > > Is there a way to tell what cells are currently selected?
> > >
> > > mtable = uitable(gcf, magic(3), {'A', 'B', 'C'});
> > > jtable = mtable.getTable;
> > > row = jtable.getSelectedRow + 1; % Java indexes start at 0
> > > col = jtable.getSelectedColumn + 1;
> > >
> > > If multiple cells are selected, you might want to use
> > > getSelectedRows and getSelectedColumns which return an array
> > > of int32 indexes (0-based).
> > >
> > > Yair
From: Bass on
In my hands the code works fine on 2009a

The jUIScrollPane handle should look like this:
jUIScrollPane =

javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane

and the jUITable something like this:

com.mathworks.hg.peer.ui.UITablePeer$22[,0,0,0x0,alignmentX=0.0,alignmentY=0.0,border=,flags=251658568,maximumSize=,minimumSize=,preferredSize=,autoCreateColumnsFromModel=true,autoResizeMode=AUTO_RESIZE_OFF,cellSelectionEnabled=false,editingColumn=-1,editingRow=-1,gridColor=javax.swing.plaf.ColorUIResource[r=212,g=208,b=200],preferredViewportSize=java.awt.Dimension[width=450,height=400],rowHeight=16,rowMargin=1,rowSelectionAllowed=true,selectionBackground=javax.swing.plaf.ColorUIResource[r=10,g=36,b=106],selectionForeground=javax.swing.plaf.ColorUIResource[r=255,g=255,b=255],showHorizontalLines=true,showVerticalLines=true]



"Adi " <Radin.Nasirudin(a)roe.med.tu-muenchen.de> wrote in message <i249m5$kj4$1(a)fred.mathworks.com>...
> hi, i've just read ur post above. i'm using MATLAB R2009a
>
> i've tried ur suggested solution, but MATLAB returns an error message after i type in:
>
> >>jUITable = jUIScrollPane.getViewport.getView;
>
> Attempt to reference field of non-structure array
>
> have i missed any step?
>
> thanks!
>
> "Bass " <bassam.atallah(a)gmail.com> wrote in message <i136c3$c9u$1(a)fred.mathworks.com>...
> > Answer my own question....
> >
> > Here is the solution for the new (after 2008a??) uitable which is actually a java UIScrollPane.
> >
> > mtable = uitable('Parent',gcf,);
> >
> > jUIScrollPane = findjobj(mtable);
> > jUITable = jUIScrollPane.getViewport.getView;
> >
> > row = jUITable.getSelectedRow + 1; % Java indexes start at 0
> > col = jUITable.getSelectedColumn + 1;
> >
> >
> >
> > "Bass " <bassam.atallah(a)gmail.com> wrote in message <i135jk$oci$1(a)fred.mathworks.com>...
> > > Thanks again Yair!
> > > This is a nice piece of code, but doesn't quite work for the new version of uitable.
> > >
> > > the new call (probably after 2008a? I am using 2010a) returns a numeric handle
> > > mtable = uitable('Parent',gcf,);
> > >
> > > I can use your findjobj to get the java object,
> > > it is:
> > > javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane
> > >
> > > I guess a UIScrollPane?
> > > which doesn't have a .getTable method.
> > > Any idea how to get the selectedRows and Columns from this?
> > >
> > > cheers
> > >
> > >
> > >
> > > "Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <fqrd8l$30$1(a)fred.mathworks.com>...
> > > > > Is there a way to tell what cells are currently selected?
> > > >
> > > > mtable = uitable(gcf, magic(3), {'A', 'B', 'C'});
> > > > jtable = mtable.getTable;
> > > > row = jtable.getSelectedRow + 1; % Java indexes start at 0
> > > > col = jtable.getSelectedColumn + 1;
> > > >
> > > > If multiple cells are selected, you might want to use
> > > > getSelectedRows and getSelectedColumns which return an array
> > > > of int32 indexes (0-based).
> > > >
> > > > Yair
From: Adi on
It worked! I must have miss something from the beginning. Thanx a lot for the assistance!

Another question, is it possible if I click a cell, the whole row would be highlighted?


"Bass " <bassam.atallah(a)gmail.com> wrote in message <i24ccc$l44$1(a)fred.mathworks.com>...
> In my hands the code works fine on 2009a
>
> The jUIScrollPane handle should look like this:
> jUIScrollPane =
>
> javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane
>
> and the jUITable something like this:
>
> com.mathworks.hg.peer.ui.UITablePeer$22[,0,0,0x0,alignmentX=0.0,alignmentY=0.0,border=,flags=251658568,maximumSize=,minimumSize=,preferredSize=,autoCreateColumnsFromModel=true,autoResizeMode=AUTO_RESIZE_OFF,cellSelectionEnabled=false,editingColumn=-1,editingRow=-1,gridColor=javax.swing.plaf.ColorUIResource[r=212,g=208,b=200],preferredViewportSize=java.awt.Dimension[width=450,height=400],rowHeight=16,rowMargin=1,rowSelectionAllowed=true,selectionBackground=javax.swing.plaf.ColorUIResource[r=10,g=36,b=106],selectionForeground=javax.swing.plaf.ColorUIResource[r=255,g=255,b=255],showHorizontalLines=true,showVerticalLines=true]
>
>
>
> "Adi " <Radin.Nasirudin(a)roe.med.tu-muenchen.de> wrote in message <i249m5$kj4$1(a)fred.mathworks.com>...
> > hi, i've just read ur post above. i'm using MATLAB R2009a
> >
> > i've tried ur suggested solution, but MATLAB returns an error message after i type in:
> >
> > >>jUITable = jUIScrollPane.getViewport.getView;
> >
> > Attempt to reference field of non-structure array
> >
> > have i missed any step?
> >
> > thanks!
> >
> > "Bass " <bassam.atallah(a)gmail.com> wrote in message <i136c3$c9u$1(a)fred.mathworks.com>...
> > > Answer my own question....
> > >
> > > Here is the solution for the new (after 2008a??) uitable which is actually a java UIScrollPane.
> > >
> > > mtable = uitable('Parent',gcf,);
> > >
> > > jUIScrollPane = findjobj(mtable);
> > > jUITable = jUIScrollPane.getViewport.getView;
> > >
> > > row = jUITable.getSelectedRow + 1; % Java indexes start at 0
> > > col = jUITable.getSelectedColumn + 1;
> > >
> > >
> > >
> > > "Bass " <bassam.atallah(a)gmail.com> wrote in message <i135jk$oci$1(a)fred.mathworks.com>...
> > > > Thanks again Yair!
> > > > This is a nice piece of code, but doesn't quite work for the new version of uitable.
> > > >
> > > > the new call (probably after 2008a? I am using 2010a) returns a numeric handle
> > > > mtable = uitable('Parent',gcf,);
> > > >
> > > > I can use your findjobj to get the java object,
> > > > it is:
> > > > javahandle_withcallbacks.com.mathworks.hg.peer.utils.UIScrollPane
> > > >
> > > > I guess a UIScrollPane?
> > > > which doesn't have a .getTable method.
> > > > Any idea how to get the selectedRows and Columns from this?
> > > >
> > > > cheers
> > > >
> > > >
> > > >
> > > > "Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <fqrd8l$30$1(a)fred.mathworks.com>...
> > > > > > Is there a way to tell what cells are currently selected?
> > > > >
> > > > > mtable = uitable(gcf, magic(3), {'A', 'B', 'C'});
> > > > > jtable = mtable.getTable;
> > > > > row = jtable.getSelectedRow + 1; % Java indexes start at 0
> > > > > col = jtable.getSelectedColumn + 1;
> > > > >
> > > > > If multiple cells are selected, you might want to use
> > > > > getSelectedRows and getSelectedColumns which return an array
> > > > > of int32 indexes (0-based).
> > > > >
> > > > > Yair