It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes JTable cell focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable cell focus" Watch "JTable cell focus" New topic

JTable cell focus


Joined: Jan 27, 2005
Posts: 13
How do u loose the focus of a selected cell in a JTable ???
todd runstein
Ranch Hand

Joined: Feb 15, 2005
Posts: 64
I don't understand? Do you want to put the focus somewhere else (click on another component)? Do you want to know when the cell loses focus (add a listener)? Perhaps you could explain a bit more about what you're trying to do?
Lilyana Saputra

Joined: Feb 03, 2006
Posts: 20
i think that he want to know is ...
how to move the focus from table to other component...

because i have same problem with that!!!

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Some possibilities might be:
1 — use JTable methods
table.clearSelection, table.changeSelection or perhaps any of several methods available in the tables ListSelectionModel obtained by table.getSelectionModel or table.getColumnModel.getSelectionModel
how to move the focus from table to other component...
2 — work with the focus subsystem
information and examples on focus control for j2se 1.4+ How to Use the Focus Subsystem in the tutorial
and The AWT Focus Subsystem in the javadocs
3 — work with the KeyboardFocusManager
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager
and calling methods like kfm.focusNextComponent and kfm.focusPreviousComponent
4 — use default LAF focus traversal with the tab key
try pressing the tab and control keys to leave the JTable.

edit - typos
[ February 28, 2006: Message edited by: Craig Wood ]
I agree. Here's the link:
subject: JTable cell focus
It's not a secret anymore!