• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JFrame  RSS feed

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I am developing a very simple application which has 6 Frames. MainFrame is the main screen and has 5 Buttons which link to the other 5 Frames.When I click Button1, it opens Frame1, button2 opens Frame2 e.t.c. I am using the following code to open the Frames.
if(e.getSource() == button1)
{
new Frame1();
}
Frame1 opens but when I click close, it closes the Main Frame and Frame1. I would want to go back to the Main screen whenever I click on close such that when I close Frame1, I go back to the Main screen and open any other Frame of my choice.
Can someone assist me on my problem with the aid of an example.
[ January 21, 2004: Message edited by: Patrick Mugabe ]
[ January 21, 2004: Message edited by: Patrick Mugabe ]
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I imagine you are using setDefaultCloseOperation?
If you are and you are using EXIT_ON_CLOSE, change it to DISPOSE_ON_CLOSE
The preferred method, however, would be to add a WindowListener:


This would be added to all child frames.
 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jason, it works.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!