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

How to set focus on one of the two JInternalFrame

Yingie Pitts
Ranch Hand

Joined: Oct 10, 2002
Posts: 37
I have two JInternalFrames A and B that are added to a JFrame. A opens the other JInternalFrame C. After C is closed, the focus always returns to B not A. Do any of you know why?


"To err is human, but to really foul things up you need a computer." Paul Ehrlich.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

This is controlled in the DesktopManager... I think the behavior of DefaultDesktopManager is just to set the focus on the first frame it gets from getComponents(). So basically the frame that has been added to the desktop the longest. Unfortunately, the method they call to do this is not part of the API, so you'll have to implement your own DesktopManager to do this in the closeFrame() method.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Romnick Malabiga
Greenhorn

Joined: Oct 20, 2012
Posts: 1
try using these methods...
.moveToFront();
.setSelected(true);

but you need to enclose the .setSelected method in a try catch block..

here's an example.. I'm using netbeans..



Hope it helps.. This is my first time to post here in coderanch..
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4541
    
    5

Romnick Malabiga wrote:try using these methods...

It's not likely that Yingie Pitts is still looking for a solution 9 years after asking the question.

Romnick Malabiga wrote:This is my first time to post here in coderanch..

Welcome to the Ranch!


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set focus on one of the two JInternalFrame