Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to set focus on one of the two JInternalFrame  RSS feed

 
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 Java Spring
  • 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
Java Netbeans IDE Opera
  • 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!
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!