posts - 2, comments - 0, trackbacks - 0, articles - 0

访QQ登陆界面

Posted on 2008-12-26 23:14 IT小兵 阅读(116) 评论(0)  编辑  收藏 所属分类: JAVA
package com.progrm.Qq;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MyQq  extends JFrame implements ActionListener {
 private ImageIcon logImg=null;
 private JLabel welcomeJL=null;
 private JLabel usenameJL=null;
 private JLabel passwordJL=null;
 private JTextField usenameJT=null;
 private JPasswordField passwordJP=null;
 private JButton loginJB=null;
 private JButton closeJB=null;
 private JPanel one=null;
 private JPanel two=null;
 private JPanel three=null;
 private JPanel four=null;
 public MyQq(String title){
  super(title);
  logImg=new ImageIcon("com/progrm/Qq/img/qq.gif") ;
  welcomeJL=new JLabel(logImg);
  usenameJL=new JLabel("帐号");
  usenameJT=new JTextField(10);
  passwordJL=new JLabel("密码");
  passwordJP=new JPasswordField(10);
  loginJB=new JButton("登陆");
  loginJB.addActionListener(this);
  closeJB=new JButton("取消");
  closeJB.addActionListener(this);
  one=new JPanel();
  one.add(welcomeJL);
  two=new JPanel();
  two.add(usenameJL);
  two.add(usenameJT);
  three=new JPanel();
  three.add(passwordJL);
  three.add(passwordJP);
  four=new JPanel();
  four.add(loginJB);
  four.add(closeJB);
  this.setLayout(new GridLayout(4,1));
  this.add(one);
  this.add(two);
  this.add(three);
  this.add(four);
  this.setSize(331,244);
  this.setLocation(520, 310);
  this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  this.setResizable(false);
  this.setVisible(true);
 }
 
 public void actionPerformed(ActionEvent e) {
  if(e.getSource()==loginJB){
   if(usenameJT.getText().equals("wl") && passwordJP.getText().equals("123")){
    JOptionPane.showMessageDialog(this,"登陆成功");
   }
   else{
    JOptionPane.showMessageDialog(this,"密码错误");
   }
  }
  if(e.getSource()==closeJB){
   System.exit(0);
  }
 }
}


public class TestQq {


 public static void main(String[] args) {
  new MyQq("QQ用户登陆");
 }

}


只有注册用户登录后才能发表评论。


网站导航: