Custom Tab order within a JTable

Hi,

     I have a JTable instance with two columns and certain number of
rows. The first column (on the left) lists the property name and right
column lists the value of the corresponding property. The property
values are editable (by the user) whereas the property names are not.
The default tab order takes a right/down approach. However I wish that
as the tab is pressed, only the editable fields (i.e. the right column
stack) get focus.
     To be clear, I want the tab order to be 

cell(0,1) -> cell(1,1) -> cell (2,1) ... cell(0,1) ...  where
cell(ROW,COL) is the cell at the intersection of row ROW and col COL.

     Do you know how is this possible. I know that the tab order can
be set for different components, but I dont know how to do it within a
JTable. Can you please help me out.

Thanks in advance,
Mahim.
0
absletters
10/11/2004 8:07:12 PM
comp.lang.java.gui 8282 articles. 0 followers. Post Follow

1 Replies
1962 Views

Similar Articles

[PageSpeed] 53

Mahim wrote:
> Hi,
> 
>      I have a JTable instance with two columns and certain number of
> rows. The first column (on the left) lists the property name and right
> column lists the value of the corresponding property. The property
> values are editable (by the user) whereas the property names are not.
> The default tab order takes a right/down approach. However I wish that
> as the tab is pressed, only the editable fields (i.e. the right column
> stack) get focus.
>      To be clear, I want the tab order to be 
> 
> cell(0,1) -> cell(1,1) -> cell (2,1) ... cell(0,1) ...  where
> cell(ROW,COL) is the cell at the intersection of row ROW and col COL.
> 
>      Do you know how is this possible. I know that the tab order can
> be set for different components, but I dont know how to do it within a
> JTable. Can you please help me out.
> 
> Thanks in advance,
> Mahim.

You can write your own Action classes that performs the appropriate cell 
navigation and link those Actions to the keys "selectNextColumnCell" and 
"selectPreviousColumnCell" in the ActionMap of the table. (These are the 
strings that map to Tab and Shift-Tab keys respectively in the default 
InputMap of a JTable).

If you do not want to rely on this implementation detail, you can modify 
the InputMap of the JTable to map the Tab / Shift-Tab keystrokes to some 
other string values, and map those strings to your custom actions in the 
ActionMap.

BK

0
Babu
10/13/2004 6:40:50 AM
Reply: