Java swing application, close one window and open another when button is clicked

前端 未结 7 1932
离开以前
离开以前 2020-12-03 07:56

I have a netbeans Java application that should display a JFrame (class StartUpWindow extends JFrame) with some options when the application is launched, then the user clicks

7条回答
  •  一生所求
    2020-12-03 08:39

    You can hide a part of JFrame that contains the swing controls which you want on another JFrame.

    When the user clicks on a Jbutton the JFrame width increases and when he clicks on another same kind of Jbutton the JFrame comes to the default size.

      JFrame myFrame = new JFrame("");
      JButton button1 = new JButton("Basic");
      JButton button2 = new JButton("More options");
     // actionPerformed block code for button1 (Default size)  
     myFrame.setSize(400, 400);
    //  actionPerformed block code for button2 (Increase width)
     myFrame.setSize(600, 400);
    

提交回复
热议问题