• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Close one Frame open another?

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
I have a JFrame with a button. When the button is pressed I want to close the current frame and open a new one.
I find that dispose() and System.exit(0) kill both frames! Any ideas?
regards
Simon Ingram
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.exit(0) stops ALL processes, including the new frame, so that's a bad idea. Just use dispose() after you create the new JFrame, and you should be fine. You may also need to change the default close operation (I think by setDefaultCloseOperation(JFrame.DEFAULT_NO_CLOSE) or something similar to that), so if just using dispose() doesn't work, check the documentation for that.
[ March 11, 2004: Message edited by: Jeremy Tartaglia ]
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Jeremy
the dispose on its own does the trick! I did not need to setDefaultCloseOperation.
Thanks once again
Simon
 
reply
    Bookmark Topic Watch Topic
  • New Topic