How to go back to a JFrames in Java

前端 未结 3 1424
别跟我提以往
别跟我提以往 2021-01-06 06:45

I have a button in a JFrame, if pressed, it takes us to another frame. I used this code:

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt         


        
3条回答
  •  隐瞒了意图╮
    2021-01-06 06:54

    you shouldn't use more then one frame.

    You should have NOTHING in JFrame except defaultExitOperation, size, preferedsize and visible true. Instead place all buttons and fields into a JPanel and add/remove the JPanel from the JFrame.

    If you want another Window open use JDialog.

    btw: you can have your MainFrame setVisible false and open a JDialog with your MainFrame as parent. Only if someone writes down the right user + password you make the MainFrame visible.

提交回复
热议问题