Forums Register Login

anchor cell return -1 for row and column

+Pie Number of slices to send: Send
hi all,
when i get focus on the anchor cell of my JTable , it returns -1 value for both row and column, and when i move it forward to the next cell in this row ,only then it selects the this row, i wanted to select this row when the anchor cell has the focus.need some help here
thanks
harcharan
+Pie Number of slices to send: Send
Hi harcharan,
What do you mean by the term anchor cell?
Michael Morris
+Pie Number of slices to send: Send
that is the first cell in JTable at position 0,0,where i get the focus with my tab key ,and at this point on , i like to select this row, but this does not happen untill i move the focus to the next cell at 0,1(row,column),i could not find in api anything like selectrow(int row),i found
isRowSelected();
setRowSelectedAllowed(true);
and i am also working with
getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column)
I am trying to select the first row ,when the focus is at cell number 0,0.Am i missing anything,or any advice will be valuable.
thanks

thanks
harcharan
[ September 26, 2002: Message edited by: harcharan kanwal ]
[ September 26, 2002: Message edited by: harcharan kanwal ]
+Pie Number of slices to send: Send
Hi harcharan,
Give us some more details on what you want to do here. Is your JTable editable, are you using a ListSelectionListener, etc.? Without a little more info we can't try any sample code.
You may try something like this:

Michael Morris
[ September 26, 2002: Message edited by: Michael Morris ]
+Pie Number of slices to send: Send
hi Michael,
i want to select a row and pop up a book dialog with this flight info using key board operation,ofcourse evreything works fine with the mouse click,my table cells are not editable,and i am not using
ListSelectionListener.is that something i have to work ,
thanks for taking me through
harcharan
+Pie Number of slices to send: Send
Hi harcharan,
Are you using the TAB key to acquire the focus? For an uneditable JTable the behavior seems to be that upon gaining the focus, nothing is selected. On the next TAB, a selection occurs. You could try something like this in your JTable (assuming you are extending JTable):

Let me say that I have no idea as to whether this is going to work or not, but it's worth a shot.
Hope this helps,
Michael Morris
+Pie Number of slices to send: Send
he michael,
i got this problem solved with this
table.setRowSelectionInterval(row, row),i can think ahead from here.
thanks for your help
+Pie Number of slices to send: Send
hi Michael,
is it ok to tell the user to use the tab key to move the focus around on components in a container
or do we have to write mnemonics .
thanks for help
harcharan
+Pie Number of slices to send: Send
Hi Harcharan,


is it ok to tell the user to use the tab key to move the focus around on components in a container


That's fine. No need to use mnemonincs. It's always better to use the default behavior if you can. CTRL+TAB is actually what is required when using a JTable, because when the JTable gets the focus, TABs move from cell to cell in the table.
Michael Morris
+Pie Number of slices to send: Send
hi Michael,
yes ctrl+tab is helpful to get the focus out from jtable to container one before the where jtable is displayed.
thanks for help
harcharan
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 969 times.
Similar Threads
problem in colors of cells JTable (check this one)
problem in colors of cells JTable
JTable and combobox as the cellEditor
Problem with a JTable
Selecting a single cell in a JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:14:11.