[Solved] Why it is happening? java [closed]


Basically, time is a repeating Swing Timer which never stops

This means that while counter2 is equal to 6….

if (counter2 == 6) {
    start1.dispose();
    buildStart2();
    //setVisible(true);
}

It will create, yet, another frame…

I would suggest…

  • Stopping the timer when you no longer need it…
  • Not using multiple frames, see The Use of Multiple JFrames, Good/Bad Practice? for more details…
  • Not putting ALL you code into a single file and separating each individual view into a separate file, extending from JPanel
  • Using CardLayout to manage the navigation between the views, see How to Use CardLayout for more details
  • Having a read through Code Conventions for the Java TM Programming Language, it will make it easier for people to read your code and for you to read others

3

solved Why it is happening? java [closed]