aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFrame focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame focus" Watch "JFrame focus" New topic
Author

JFrame focus

Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
Hi,
I have two co-dependent JFrames.
A button in Frame1 opens up Frame2, and Frame2 accepts some input.
The input in frame2 has some calculations done on it after a click event on frame1. The calculations are based on the location clicked in frame1.

What happens by default is; frame2 opens up, I give it some input, and then when I click on frame1 (to give frame2 the location to base its calculations on) frame2 disappears behind frame1, as it has lost its focus.

Is there a way of changing the focus so that when I click on frame1, the click will register, but frame2 will stay in focus and stay on top?

Thanks for your time,

Eoin.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40061
    
  28
Have you checked whether JFrames have a requestFocus() method? If they have, then try putting something like:-
in the actionListener for your button on Frame 1. If that doesn't work, have you tried "toFront()" and "toBack()" methods?

Just suggestions; I hope they work
CR
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame focus