• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

How to set focus on one of the two JInternalFrame

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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!
 
No holds barred. And no bars holed. Except this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!