• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Losing focus after bringing another window into focus

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic