使用java swing實(shí)現(xiàn)qq登錄界面示例分享
更新時(shí)間:2014年04月01日 14:20:23 作者:
這篇文章主要介紹了使用java swing實(shí)現(xiàn)qq登錄界面示例,需要的朋友可以參考下
用Java Swing做的一個(gè)QQ登錄界面
復(fù)制代碼 代碼如下:
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;
/**
* 仿QQ登錄界面
*
* @author jiang
*/
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("QQ2012正式版");
// 窗體組件初始化
init();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 設(shè)置布局方式為絕對(duì)定位
this.setLayout(null);
this.setBounds(0, 0, 355, 265);
// 設(shè)置窗體的標(biāo)題圖標(biāo)
Image image = new ImageIcon("e:/a.gif").getImage();
this.setIconImage(image);
// 窗體大小不能改變
this.setResizable(false);
// 居中顯示
this.setLocationRelativeTo(null);
// 窗體可見
this.setVisible(true);
}
/*
* 初始化方法
*/
public void init() {
// 創(chuàng)建一個(gè)容器
Container con = this.getContentPane();
jl1 = new JLabel();
// 設(shè)置背景圖片
Image image1 = new ImageIcon("e:/background.jpg").getImage();
jl1.setIcon(new ImageIcon(image1));
jl1.setBounds(0, 0, 355, 265);
// QQ登錄頭像設(shè)定
jl2 = new JLabel();
Image image2 = new ImageIcon("e:/a.gif").getImage();
jl2.setIcon(new ImageIcon(image2));
jl2.setBounds(40, 95, 50, 60);
// 用戶號(hào)碼登錄輸入框
username = new JTextField();
username.setBounds(100, 100, 150, 20);
// 用戶號(hào)碼登錄輸入框旁邊的文字
jl3 = new JLabel("注冊(cè)賬號(hào)");
jl3.setBounds(260, 100, 70, 20);
// 密碼輸入框
password = new JPasswordField();
password.setBounds(100, 130, 150, 20);
// 密碼輸入框旁邊的文字
jl4 = new JLabel("找回密碼");
jl4.setBounds(260, 130, 70, 20);
// 輸入框下方文字
jc1 = new JCheckBox("記住密碼");
jc1.setBounds(105, 155, 80, 15);
jc2 = new JCheckBox("自動(dòng)登錄");
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(280, 200, 65, 20);
// 給按鈕添加1個(gè)事件
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();
JOptionPane.showConfirmDialog(null, "您輸入的用戶名是"+getName);
}
}
});
bu2 = new JButton("多賬號(hào)");
bu2.setBounds(5, 200, 75, 20);
bu3 = new JButton("設(shè)置");
bu3.setBounds(100, 200, 65, 20);
// 所有組件用容器裝載
jl1.add(jl2);
jl1.add(jl3);
jl1.add(jl4);
jl1.add(jc1);
jl1.add(jc2);
jl1.add(jcb);
jl1.add(bu1);
jl1.add(bu2);
jl1.add(bu3);
con.add(jl1);
con.add(username);
con.add(password);
}
public static void main(String[] args) {
// 實(shí)例化對(duì)象
GUIQQ qq = new GUIQQ();
}
}
相關(guān)文章
Spring Cache整合Redis實(shí)現(xiàn)方法詳解
這篇文章主要介紹了Spring Cache整合Redis實(shí)現(xiàn)方法詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08Springboot接入MyBatisPlus的實(shí)現(xiàn)
最近web端比較熱門的框架就是SpringBoot和Mybatis-Plus,這里簡單總結(jié)集成用法,具有一定的參考價(jià)值,感興趣的可以了解一下2023-09-09spring boot springMVC擴(kuò)展配置實(shí)現(xiàn)解析
這篇文章主要介紹了spring boot springMVC擴(kuò)展配置實(shí)現(xiàn)解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-08-08Spring MVC url提交參數(shù)和獲取參數(shù)
本文重要講述通過url提交參數(shù)和獲取參數(shù)的具體操作與實(shí)現(xiàn)。具有很好的參考價(jià)值。下面跟著小編一起來看下吧2017-04-04interrupt()和線程終止方式_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
線程的thread.interrupt()方法是中斷線程,將會(huì)設(shè)置該線程的中斷狀態(tài)位,即設(shè)置為true,中斷的結(jié)果線程是死亡、還是等待新的任務(wù)或是繼續(xù)運(yùn)行至下一步,就取決于這個(gè)程序本身2017-05-05springboot?vue前后端接口測試樹結(jié)點(diǎn)添加功能
這篇文章主要為大家介紹了springboot?vue前后端接口測試樹結(jié)點(diǎn)添加功能,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05