• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to know if I got focus

 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I can't determine if my JTable has the focus, I have invoked the isFocusOwner method, but seem to always get false, even after I have clicked on the JTable?
I need to know when the table has focus and has lost focus. How do I do this?
thanks,
Sarone
 
Krishna Mohan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this helps.
web page
view the complete thread for the entire discussion.
-Krishna
 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is just a problem, no answer, unless i'm missing something here. this person has the same problem as me.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
 
Sarone Thach
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it have to be a JFrame? Can I have a JPanel that implements FocusListener?
Kind of weird but I'm not getting any FocusGained or FocusLost events.
I have a JFrame, if I click a button in the JFrame it opens a JDialog box, its modal. Within the JDialog box is a JTabPane, in the TabPane is a Pane, in the Panel is a JSplitPane, in each of the splitPane is a JScrollPane, in the Scrollpane is a JTable.
Do I need to addFocusListener for each one of these? Cause I tried that too and it doesn't work for me :-(
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try registering a WindowListener with the JDialog and within windowActivated ask the java.awt.KeyboardFocusManager for the focus owner.
Read this section of the
Java Tutorial. for more ideas.
[ December 23, 2003: Message edited by: Jose Botella ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!