溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

java實(shí)現(xiàn)qq登錄頁面

發(fā)布時間:2020-05-30 01:16:04 來源:億速云 閱讀:282 作者:鴿子 欄目:編程語言

用java仿制qq
直奔主題,代碼如下
import java.awt.Color;
import java.awt.Container;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class GUIQQ extends JFrame {
// 用戶名
private JTextField username;
// 密碼
private JPasswordField password;
// 小容器
private JLabel jl1;
private JLabel jl2;
private JLabel jl3;
private JLabel jl4;
// 小按鈕
private JButton bu1;
private JButton bu2;
private JButton bu3;
// 復(fù)選框
private JCheckBox jc1;
private JCheckBox jc2;
// 列表框
private JComboBox jcb;
/*

  • 構(gòu)造方法
    /
    public GUIQQ() {
    // 設(shè)置窗口標(biāo)題
    this.setTitle("QQ");
    // 窗體組件初始化
    init();
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // 設(shè)置布局方式為絕對定位
    this.setLayout(null);
    this.setBounds(0, 0, 355, 265);
    // 設(shè)置窗體的標(biāo)題圖標(biāo)
    Image image = new ImageIcon("image//T83XSMYF}~B)$$6}XYZ4KM3.png").getImage();
    this.setIconImage(image);
    // 窗體大小不能改變
    this.setResizable(false);
    // 居中顯示
    this.setLocationRelativeTo(null);
    // 窗體可見
    this.setVisible(true);
    }
    /
  • 初始化方法
    */
    public void init() {
    // 創(chuàng)建一個容器
    Container con = this.getContentPane();
    jl1 = new JLabel();
    // 設(shè)置背景圖片
    Image image1 = new ImageIcon("image//2BF5MB~_47SZRCV`SEL44OD.png").getImage();
    jl1.setIcon(new ImageIcon(image1));
    jl1.setBounds(0, 0, 355, 265);
    // QQ登錄頭像設(shè)定
    jl2 = new JLabel();
    Image image2 = new ImageIcon("image//D0PCQ~_MI}A1M9ZF8Z]M0T7.png").getImage();
    jl2.setIcon(new ImageIcon(image2));
    jl2.setBounds(40, 95, 50, 60);
    // 用戶號碼登錄輸入框
    username = new JTextField();
    username.setBounds(100, 100, 150, 20);
    // 用戶號碼登錄輸入框旁邊的文字
    jl3 = new JLabel("注冊賬號");
    jl3.setBounds(260, 100, 70, 20);
    jl3.setForeground(Color.BLUE);
    // 密碼輸入框
    password = new JPasswordField();
    password.setBounds(100, 130, 150, 20);
    // 密碼輸入框旁邊的文字
    jl4 = new JLabel("找回密碼");
    jl4.setBounds(260, 130, 70, 20);
    jl4.setForeground(Color.BLUE);
    // 輸入框下方文字
    jc1 = new JCheckBox("記住密碼");
    jc1.setBounds(105, 155, 80, 15);
    jc2 = new JCheckBox("自動登錄");
    jc2.setBounds(185, 155, 80, 15);
    // 用戶登錄狀態(tài)選擇
    jcb = new JComboBox();
    jcb.addItem("在線");
    jcb.addItem("隱身");
    jcb.addItem("離開");
    jcb.setBounds(40, 150, 55, 20);
    // 按鈕設(shè)定
    bu1 = new JButton("登錄");
    bu1.setBounds(100, 175,150,30);
    // 給按鈕添加1個事件
    bu1.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
    String str=e.getActionCommand();
    if("登錄".equals(str)){
    String getName =username.getText();
    // String getPwd =password.getText();
    String userpassword = new String(password.getPassword());

String sql ="secelt * from  while name='"username"'and psw'"=userpassword'"";
JOptionPane.showConfirmDialog(null,"您輸入的用戶名是"+getName);
}
}
});
jl1.add(jl2);
jl1.add(jl3);
jl1.add(jl4);
jl1.add(jc1);
jl1.add(jc2);
jl1.add(jcb);
jl1.add(bu1);
con.add(jl1);
con.add(username);
con.add(password);
}
public static void main(String[] args) {
// 實(shí)例化對象
GUIQQ qq = new GUIQQ();
}
}

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI