How to disable main JFrame when open new JFrame

后端 未结 5 1540
旧时难觅i
旧时难觅i 2020-12-03 14:28

Example now I have a main frame contains jtable display all the customer information, and there was a create button to open up a new JFrame that allow user to create new cus

5条回答
  •  一个人的身影
    2020-12-03 14:51

    just use firstFrame.setVisible(false) on the first frame. This will make it hidden..

    if you want a more general approach you could have a reference to the current displayed frame somewhere and change it when a new frame requests to be shown

    JFrame currentFrame;
    
    void showRequest(JFrame frame)
    {
      currentFrame.setVisible(false);
      currentFrame = frame;
      currentFrame.setVisible(true);
    }
    

提交回复
热议问题