• 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

JFrame Help Please

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

Basically i havn't programmed for quite a while now and am trying to get back into it, i am trying to make a little application with a JFrame, and here is the code I have produced...



Basically, I have created a little JFrame with some layout and 2 main buttons...and this is in a file called titleFrame.java....what I want to do though, is when the 'New' Button is pressed, i would like it to call another seperate class i have created, main.java....whereby in that java file it is like this one, but with different buttons and all....

I think this is really simple to achieve, i just simply cannot remmeber what to do, if anyone can help it would be superb! Also, when the 'Exit' button is pushed, what is the correct syntax to close the JFrame, I need to catch back up on this but im starting to get back into it.

Mank Thanks,

Ben
 
ben williamson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have managed to solve this, but i stil cannot get the first window to close then the second is created, anyone know how to do this??

thansk
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to call frame.dispose() on the frame you want to make go away. That said, the better approach would be to simply swap out your JPanel with a new JPanel that contains all the components you want.
 
reply
    Bookmark Topic Watch Topic
  • New Topic