Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JTable: Setting tab order

42 views
Skip to first unread message

Phillip Lawes

unread,
Jun 19, 2001, 2:54:17 PM6/19/01
to
Hello all,

Lets say that I have a table with ten rows and five columns. The default
tab order tabs through each cell, left to right, top to bottom.

How do I EXCLUDE the cells of the two leftmost columns from the tab
order?

Many thanks in advance, especially for any sample code.

Christian Kaufhold

unread,
Jun 19, 2001, 4:26:53 PM6/19/01
to
Phillip Lawes <pkl_...@hotmail.com> wrote:

> Lets say that I have a table with ten rows and five columns. The default
> tab order tabs through each cell, left to right, top to bottom.

> How do I EXCLUDE the cells of the two leftmost columns from the tab
> order?

I doubt it can be done but by rewriting the actions completely.


table.getInputMap().put("TAB", "tabForwards");
table.getInputMap().put("shift TAB", "tabBackwards");

table.getActionMap().put("tabForwards", new XXXAction());
table.getActionMap().put("tabBackwards", new YYYAction());


and do whatever you want to in XXXAction and YYYAction.

See BasicTableUI.NavigationalAction for inspiration.

Christian

Christian Kaufhold

unread,
Jun 19, 2001, 4:56:00 PM6/19/01
to
Christian Kaufhold <use...@chka.de> wrote:

[...]


> table.getInputMap().put("TAB", "tabForwards");
> table.getInputMap().put("shift TAB", "tabBackwards");


First replace "TAB" by KeyStroke.getKeyStroke("TAB") and so on.

Then you also (only?) need:

table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(...);

for both keys.


Christian

0 new messages