• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I cannot for the *life* of me set the focus to my desired window.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been at this for hours. I've now distilled it down to a very simple test program. First, I'm running JRE 7 on Linux (I've heard that can make a difference). Here is what I'd like the following program to do:

1. Open 3 windows
2. Set the focus to "TestWindow 1"

What it actually does:

1. Opens 3 windows
2. Sets the focus typically to "TestWindow 3" and sometimes to "TestWindow 2"

After much reading, I've moved the focus request (and almost everything else gui related for that matter) into the event dispatch thread.

Please let me know your ideas! Now I'm dying of curiosity as to the solution.

Class TestWindow


Class Main
 
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//jFrame.requestFocusInWindow();
jFrame.toFront();
 
Clayton Burke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*sigh*

I was hoping for something more esoteric. That would mean the hours I spent trying to figure this out had some meaning :-) At least I learned all about the EDT, which was a new topic for me.

Worked perfectly. Thank you much!
 
reply
    Bookmark Topic Watch Topic
  • New Topic