aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes I cannot for the *life* of me set the focus to my desired window. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I cannot for the *life* of me set the focus to my desired window." Watch "I cannot for the *life* of me set the focus to my desired window." New topic
Author

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

Clayton Burke
Greenhorn

Joined: May 19, 2009
Posts: 7
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

Joined: Jun 09, 2003
Posts: 4632
//jFrame.requestFocusInWindow();
jFrame.toFront();
Clayton Burke
Greenhorn

Joined: May 19, 2009
Posts: 7
*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!
 
jQuery in Action, 2nd edition
 
subject: I cannot for the *life* of me set the focus to my desired window.