天天看點

java仿qq登陸界面

以前寫過一次 隻不過有點簡陋  就又寫了一個。。

package qq登陸;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.swing.*;
public class qq登陸{
  public static void main(String args[]){
    QQLogin qq=new QQLogin();
  }
}
class QQLogin extends JFrame implements ActionListener,MouseListener{
  JLabel bq_North,bq_name,bq_pwd,bq_forget,bq_protect;
  JButton login,cancel,sweep,myBlog;
  JTextField text_name,text_pwd;
  JTabbedPane choose;
  JCheckBox steal_login,mark_name;
  JPanel choose1,choose2,login_South;
  String url;
  QQLogin(){
    bq_North=new JLabel(new ImageIcon("image/1.jpg"));
    login_South=new JPanel();
    login=new JButton("登陸");
    cancel=new JButton("取消");
    myBlog=new JButton("我的部落格");
    login_South.add(login);
    login_South.add(cancel);
    login_South.add(myBlog);
    choose=new JTabbedPane();
    choose1=new JPanel();
    choose2=new JPanel();
    choose.add("普通使用者",choose1);
    choose.add("會員使用者",choose2);
    choose1.setLayout(new GridLayout(3,3));
    bq_name=new JLabel("QQ賬号",JLabel.CENTER);
    bq_pwd=new JLabel("QQ密碼",JLabel.CENTER);
    sweep=new JButton("清除号碼");
    text_name=new JTextField();
    text_pwd=new JTextField();
    bq_forget=new JLabel("忘記密碼",JLabel.CENTER);
    bq_forget.setFont(new Font("宋體",Font.PLAIN,16));
    bq_forget.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    bq_forget.setForeground(Color.blue);
    steal_login=new JCheckBox("隐身登陸");
    mark_name=new JCheckBox("記住密碼");
    bq_protect=new JLabel("申請密碼保護");
    bq_protect.setForeground(Color.blue);
    bq_protect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    choose1.add(bq_name);choose1.add(text_name);choose1.add(sweep);
    choose1.add(bq_pwd);choose1.add(text_pwd);choose1.add(bq_forget);
    choose1.add(steal_login);choose1.add(mark_name);choose1.add(bq_protect);
    add(choose,BorderLayout.CENTER);
    add(bq_North,BorderLayout.NORTH);
    add(login_South,BorderLayout.SOUTH);
    login.addActionListener(this);
    cancel.addActionListener(this);
    sweep.addActionListener(this);
    myBlog.addActionListener(this);
    bq_protect.addMouseListener(this);
    bq_forget.addMouseListener(this);
    ImageIcon tubiao=new ImageIcon("image/2.jpg");
    setIconImage(tubiao.getImage());
    setVisible(true);
    setBounds(340,270,300,280);
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("qq登陸");
  }
  public void actionPerformed(ActionEvent e){
    if(e.getSource()==login)
    JOptionPane.showConfirmDialog(this, "登陸成功!!!","消息對話框",JOptionPane.WARNING_MESSAGE);
    else if(e.getSource()==cancel){
      this.dispose();
    }
    else if(e.getSource()==sweep){
      text_name.setText(null);
      text_pwd.setText(null);
    }
    else if(e.getSource()==myBlog){
      browse
    }
  }
  public void mouseClicked(MouseEvent e) {
     if(e.getSource()==bq_protect){
       browse("http://aq.qq.com");
     }
     else if(e.getSource()==bq_forget){
       browse("http://aq.qq.com");
     }
   }
  public void mousePressed(MouseEvent e) {
    
  }
  public void mouseReleased(MouseEvent e) {
    
  }
  public void mouseEntered(MouseEvent e) {
    
  }
  public void mouseExited(MouseEvent e) {
    
  }
  void browse(String url){
    Desktop desktop = Desktop.getDesktop();
    try {
        desktop.browse(new URI(url));
        } catch (IOException e1) {
      e1.printStackTrace();
        } catch (URISyntaxException e1) {
      e1.printStackTrace();
        }
  }
}      

就貼一個界面把 其實點選某些按鈕或者标簽會有回報的,比如點選我的部落格按鈕就會進入我的部落格首頁哦//。