-1

I am coding a GUI quiz and I want it so that when I press "Start" It opens a new window which will be the start of the quiz <--- (Accomplished). I also want the other page I clicked "start" on to go away so there's only 1 window open when doing the quiz. I figured if I could add 2 commands to a JButton and activate both of them with 1 click of the button it would work. Any help?

JButton btnStart = new JButton("Start");    
btnStart.setFont(newFont("HP Simplified Light", Font.PLAIN, 22));
btnStart.addActionListener(new ActionListener() {       
    public void actionPerformed(ActionEvent e) {
         Frame2 nw = new Frame2();
         nw.NewScreen();

1 Answers1

0

First way:

After nw.NewScreen(); add the Code to make first JFrame invisible.

Second way:

button.addActionListener(..) button.addActionListener(..) adding 2 actionListeners to the same button.

But in your case just follow the first way.Except if your app lags until the new Frame is shown then you have to use Threads to show that something is loading.

GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93