-3

I've a program that starts with a welcomeScreen JFrame, on which it has a JButton with the option of starting the game.. when I click that button, it opens the JFrame with my game however it does not close.. anyway of how to do this? I only know System.exit(0) and this closes everything..

mKorbel
  • 109,107
  • 18
  • 130
  • 305
mhalabi
  • 31
  • 6

2 Answers2

3

I've a program that starts with a welcomeScreen JFrame, on which it has a JButton with the option of starting the game.. when I click that button, it opens the JFrame with my game however it does not close.. anyway of how to do this? I only know System.exit(0) and this closes everything..

  • don't to create another JFrame

  • use CardLayout with JFrame.pack(), after card is switched

mKorbel
  • 109,107
  • 18
  • 130
  • 305
2

You can try: jFrame.dispose();

Random42
  • 8,629
  • 6
  • 52
  • 83