qq.java

来源:互联网 发布:施工进度计划软件 编辑:程序博客网 时间:2024/04/30 10:36

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
class myFrame extends JFrame
{      

       Box box1,box2,box3,box4,box5; Button f1,f2;
       Label la;ImageIcon icon=new ImageIcon("http_imgload[3].gif");
       TextField te1,te2;
       M m=new M();
       myFrame(String s)
      {super(s);
       setBackground(Color.LIGHT_GRAY);
       setResizable(false);
       box1=Box.createHorizontalBox();
       box1.add(new Label("用户名:"));
       box1.add(Box.createHorizontalStrut(30));
       te2=new TextField(20);    
       box1.add(te2);
       box1.add(new Label("注册新账户"));
       setIconImage(icon.getImage());
       box2=Box.createHorizontalBox();      
       box2.add(new Label("密码:"));
       box2.add(Box.createHorizontalStrut(30));
       te1=new TextField(20);
       te1.setEchoChar('*');      
       box2.add(te1);
       box2.add(new Label("找回密码"));

       box3=Box.createHorizontalBox();
       f2=new Button("登录");
       box3.add(f2);
       f2.addActionListener(new M());
       box3.add(Box.createVerticalStrut(20));
       box3.add(Box.createHorizontalStrut(40));
       f1=new Button("退出");
       box3.add(f1);
       f1.addActionListener(new M());

       box4=Box.createHorizontalBox();
       box4.add(new Label("状态:"));
       box4.add(Box.createHorizontalStrut(15));
       Choice c=new Choice();
       c.add("我在线上");
       c.add("离开");
       c.add("忙碌");
       c.add("隐身");
       c.add("请勿打扰");
       box4.add(c);box4.add(Box.createHorizontalStrut(30));
       Checkbox a1=new Checkbox("记住密码");
       Checkbox a2=new Checkbox("自动登陆");
       box4.add(a1);box4.add(a2);
       box4.add(Box.createVerticalStrut(10));
      
     
      add(box1);  add(box2); add(box4); add(box3);
      setLayout(new FlowLayout());
      la=new Label(); add(la);                             
      
      addWindowListener(new WindowAdapter()
            {
                  public void windowClosing(WindowEvent e)
                         {System.exit(0);}
            });
      setBounds(500,400,340,200);
      setVisible(true); 
    }
   class M implements ActionListener
    {
        public void actionPerformed(ActionEvent e)
            {
               if(e.getSource()==f1)
                  dispose();
               if(e.getSource()==f2)
                  {   String a=te2.getText(); String c=te1.getText();                                       
                     if(a.equals("279556122")&&c.equals("15238218929"))
                         {   
                              Frame f=new Frame();setLayout(new FlowLayout()); f.setResizable(false);                            
                              Label b=new Label("            登陆成功");
                              f.add(b);la.setText(null);
                              f.setBounds(550,450,150,100);
                              f.setVisible(true);
                              f.addWindowListener(new WindowAdapter()
                                 {
                                     public void windowClosing(WindowEvent e)
                                          {System.exit(0);}
                                  });
                          }
                     else
                         {                                                                                      
                              la.setText("您输入的账号或密码有误,请重新输入!!");
                              la.setBounds(500,600,340,200); validate();                            
                             
                          }
                   }
             }
     }    
}
public class qq
{
  public static void main(String[] args)
    {
        new myFrame("QQ登陆界面");
     }
}
 

原创粉丝点击