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

Is there a way to make VK_SPACE act a VK_TAB in JTable?

0 views
Skip to first unread message

xxu

unread,
Nov 22, 2001, 4:12:10 PM11/22/01
to
I have tried to add a KeyListener inside my JTable, the code look like
this.

class KL extends KeyAdapter {
public void keyPressed(KeyEvent e)
{
char c = e.getKeyChar();

if (c==KeyEvent.VK_SPACE) {
c = KeyEvent.VK_TAB;
e.setKeyChar(c);
}

This didn't seems to work!

Paul Lutus

unread,
Nov 22, 2001, 4:51:38 PM11/22/01
to
"xxu" <for...@tek.com> wrote in message news:3BFD6A28...@tek.com...

It didn't work because it is not an instance of a KeyAdapter, it is a
KeyAdapter class definition. You must make one. Saying how the class is
defined is not enough.

It is the difference between owning a blueprint for a car, and actually
driving that car.

--
Paul Lutus
www.arachnoid.com


xxu

unread,
Nov 22, 2001, 5:18:05 PM11/22/01
to
Well, I did create a instance of this handler and registered this to my
JTable. Trust me, the following three lines of code just works fine inside the
KeyAdapter.
c = Character.toUpperCase(c);
e.setKeyChar(c); //Must call this to set the new char
System.out.println(c);
But not the VK_TAB key.

Paul Lutus

unread,
Nov 22, 2001, 5:40:50 PM11/22/01
to
"xxu" <for...@tek.com> wrote in message news:3BFD799C...@tek.com...

> Well, I did create a instance of this handler and registered this to my
> JTable.

Well, you didn't either say that or post the code.

> Trust me, the following three lines of code just works fine inside the
> KeyAdapter.
> c = Character.toUpperCase(c);
> e.setKeyChar(c); //Must call this to set the new char
> System.out.println(c);

Trust me, you need to post the code that is at issue. Without this code, the
issue is its absence.

> But not the VK_TAB key.

The tab key is handled separately, by the focus manager. Read some recent
posts on this issue:

http://groups.google.com/groups?q=java+%22focus+manager%22+%22Tab+key%22&hl=
en


--
Paul Lutus
www.arachnoid.com


0 new messages