• Post Reply Bookmark Topic Watch Topic
  • New Topic

Losing focus after bringing another window into focus  RSS feed

 
Anne Forumer
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDK 1.3:

I have a JPanel. Focus, in this panel, could be on a JButton or JTextField. But if I bring into focus another browser window and revert back to JPanel, the JButton or JTextField doesn't have the focus any more!

Could somebody explain why this happens and what could be done to prevent this from happening so the component retains it's focus.

Thanks.
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've had similar probs, but i'm using 1.4.x. some probs were related to bizarre behavior following a load of window events

i don't know why the focus is lost - there have been several focus mods to awt and swing, and focus defaults are also influenced by platform (esp pre 1.4)...

have you tried

requestFocus (1.3)
requestFocusInWindow (1.4)

on the component(s) in question? (you would need to invoke requestFocus/requestFocusInWindow after the component is visible.)

however, this may not give you the granularity you want in focus retention...

worst case, you can try writing an intelligent windowListener to save/restore focus on windowActivated etc

good luck!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!