public class LoginForm { private JTextField UserTest; private JPanel LoginMainPanel; private JPasswordField PWText; private JButton LoginBut; public LoginForm() { JFrame frame = new JFrame("LoginForm"); frame.setContentPane(LoginMainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setSize(320,180); frame.setResizable(false);//设置不可拉伸 frame.setLocationRelativeTo(null);//设置屏幕居中 frame.setVisible(true); LoginBut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { OperationForm form = new OperationForm(); frame.dispose(); } }); } public static void main(String[] args) { new LoginForm(); } }
public class OperationForm { private JPanel OpMainPanel; public OperationForm() { JFrame frame = new JFrame("OperationForm"); frame.setContentPane(OpMainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setSize(800,600); frame.setResizable(false);//设置不可拉伸 frame.setLocationRelativeTo(null);//设置屏幕居中 frame.setVisible(true); } }