请问我用纯java编写界面,比如我先编写了登陆界面,经过和后台数据库验证后,进入系统界面
怎样实现让登陆界面消失,同时显示系统界面。而不是登陆成功后改登陆界面还存在呢?调用什么方法亚

解决方案 »

  1.   

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;class test
    {
    private static JFrame frame;
    private static JPanel panel;
    private JButton btn;

    public test()
    {
    panel = new JPanel();
    btn = new JButton("go to other gui");


    btn.addActionListener(
    new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    JOptionPane.showMessageDialog(frame, "go to other frame");
    //System.exit(0);
    frame.setVisible(false);

    frame = new JFrame("the second frame");

    frame.setBounds(10,10,500,500);
    frame.setVisible(true);
    }
    }
    );


    panel.add(btn);
    }

    public static void main(String[] args)
    {
    test gui = new test();
    frame = new JFrame("the first frame");
    frame.addWindowListener(
    new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    }
    );
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setBounds(10,10,300,300);
    frame.setVisible(true);
    }
    }
      

  2.   

    验证通过之后登陆界面dispose(),然后系统界面serVisible(true)