• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Clayton Burke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//jFrame.requestFocusInWindow();
jFrame.toFront();
 
Clayton Burke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic