窗口切换

package 窗口切换;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class Sam implements ActionListener {
       JFrame f;
       JPanel p;
       JButton b;
       JLabel l;
       JLabel l2;
       JTextField t;
       JPasswordField t2;
       public Sam(){
              f=new JFrame();
              p=new JPanel();
              l=new JLabel("账号:");
              t=new JTextField(10);
              l2=new JLabel("密码:");
              t2=new JPasswordField(10);
              b=new JButton("确定");
              f.add(p);
              p.add(l);
              p.add(t);
              p.add(l2);
              p.add(t2);
              p.add(b);
              p.setBackground(Color.blue);
              
              f.setBounds(600, 300,180,150);
              f.setVisible(true);
             b.addActionListener(this);
       } 
       public void Sam(){
              f=new JFrame();
              p=new JPanel();
              l=new JLabel("网络未连接,请稍后重试");
              f.add(p);
              p.add(l);
              f.setBounds(600,330,180,70);
              p.setBackground(Color.pink);
              f.setVisible(true);
//              b.addActionListener(this);
          }
       
       public void actionPerformed(ActionEvent arg0) {
              // TODO Auto-generated method stub
                    Sam();
       }
             

    public static void main(String[] args) {
        new Sam();

    }


}

 

posted on 2019-05-16 22:51  枫少少  阅读(95)  评论(0编辑  收藏  举报

导航