Add event(keyListener) to JTable Cell default editor.

I've got a form(Jdialog) with a Jtable on it.

I've added a keyListener to the JButtons and Jtable so that, wherever the the focus IS, when I hit the "F7" key, it fills the Jtable from the database connection.

It's working REALLY fine now but there is one small glitch.

When I'm editing a cell, the keyListener event is not thrown. I supposed it's because the "DefaultCellEditor" does not throw the event.

How can I add such a thing?

I'm looking for something like :

table.getDefaultEditor().addKeyListener

but it does not exists.

If it's not possible, is there a way to make the JDialog listen to all the keyListener events from its childs?(Mimics the JDK < 1.4)

Thx

[737 byte] By [marseilpa] at [2007-11-26 16:21:56]
# 1
Use key binding.Read this: http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html
Rodney_McKaya at 2007-7-8 22:45:40 > top of Java-index,Desktop,Core GUI APIs...
# 2
That didn't do it. A JTable does not support Action(or I did not find how)..here's my solution :((DefaultCellEditor)myTable.getDefaultEditor(String.class)).getComponent().addKeyListener(myKeyListener)
marseilpa at 2007-7-8 22:45:40 > top of Java-index,Desktop,Core GUI APIs...
# 3

Using key binding is better implementation.

After you read the tutorial your next move is to google for it.

http://www.google.com/search?hl=en&q=jtable+keybinding

Second result brings you to camickr's example:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=657819

Rodney_McKaya at 2007-7-8 22:45:40 > top of Java-index,Desktop,Core GUI APIs...
# 4
Alright, that did the trick.I google it, found that page before but at the time, I felt like this was not a simple solution.Working fine now, thx.
marseilpa at 2007-7-8 22:45:40 > top of Java-index,Desktop,Core GUI APIs...