日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java实现简单QQ登录界面

發(fā)布時(shí)間:2024/8/1 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java实现简单QQ登录界面 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本文實(shí)例為大家分享了java實(shí)現(xiàn)簡單QQ登錄界面的具體代碼,供大家參考,具體內(nèi)容如下

java在圖形界面,不是太強(qiáng)項(xiàng),但不是不可以做,它的開源是very nice!

實(shí)現(xiàn)代碼如下(想實(shí)現(xiàn)完美的界面,可能要更多coding的支持):

package com.ts.x.swing; import java.awt.Color; import java.awt.Container; import java.awt.Cursor; import java.awt.Font; 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.JRootPane; import javax.swing.JTextField; public class QQ extends JFrame{ private static final long serialVersionUID = -6788045638380819221L; //用戶名 private JTextField ulName; //密碼 private JPasswordField ulPasswd; //小容器 private JLabel j1; private JLabel j2; private JLabel j3; private JLabel j4; //小按鈕 private JButton b1; private JButton b2; private JButton b3; //復(fù)選框 private JCheckBox c1; private JCheckBox c2; //列表框 private JComboBox<String> cb1; /** * 初始化QQ登錄頁面 * */ public QQ(){ //設(shè)置登錄窗口標(biāo)題 this.setTitle("QQ登錄"); //去掉窗口的裝飾(邊框) // this.setUndecorated(true); //采用指定的窗口裝飾風(fēng)格 this.getRootPane().setWindowDecorationStyle(JRootPane.NONE); //窗體組件初始化 init(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //設(shè)置布局為絕對定位 this.setLayout(null); this.setBounds(0, 0, 355, 265); //設(shè)置窗體的圖標(biāo) Image img0 = new ImageIcon("D:/logo.png").getImage(); this.setIconImage(img0); //窗體大小不能改變 this.setResizable(false); //居中顯示 this.setLocationRelativeTo(null); //窗體顯示 this.setVisible(true); } /** * 窗體組件初始化 * */ public void init(){ //創(chuàng)建一個(gè)容器,其中的圖片大小和setBounds第三、四個(gè)參數(shù)要基本一致(需要自己計(jì)算裁剪) Container container = this.getContentPane(); j1 = new JLabel(); //設(shè)置背景色 Image img1 = new ImageIcon("D:/bgimg.png").getImage(); j1.setIcon(new ImageIcon(img1)); j1.setBounds(0, 0, 355, 265); //qq頭像設(shè)定 j2 = new JLabel(); Image img2 = new ImageIcon("D:/hdimg.png").getImage(); j2.setIcon(new ImageIcon(img2)); j2.setBounds(40, 95, 50, 53); //用戶名輸入框 ulName = new JTextField(); ulName.setBounds(100, 100, 150, 20); //注冊賬號 j3 = new JLabel("注冊賬號"); j3.setBounds(260, 100, 70, 20); //密碼輸入框 ulPasswd = new JPasswordField(); ulPasswd.setBounds(100, 130, 150, 20); //找回密碼 j4= new JLabel("找回密碼"); j4.setBounds(260, 130, 70, 20); //記住密碼 c1 = new JCheckBox("記住密碼"); c1.setBounds(105, 155, 80, 15); //自動(dòng)登陸 c2 = new JCheckBox("自動(dòng)登陸"); c2.setBounds(185, 155, 80, 15); //用戶登陸狀態(tài)選擇 cb1 = new JComboBox<String>(); cb1.addItem("在線"); cb1.addItem("隱身"); cb1.addItem("離開"); cb1.setBounds(40, 150, 55, 20); //登陸按鈕 b1 = new JButton("登錄"); //設(shè)置字體和顏色和手形指針 b1.setFont(new Font("宋體", Font.PLAIN, 12)); b1.setForeground(Color.RED); b1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); b1.setBounds(280, 200, 65, 20); //給按鈕添加 b1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if("登錄".equals(cmd)){ String username = ulName.getText(); String userpassword = ulPasswd.getText(); if(username.equals("tskk") && userpassword.equals("123456")){ JOptionPane.showConfirmDialog(null, "登錄成功"); }else{ JOptionPane.showConfirmDialog(null, "登錄失敗"); } } } }); //多賬號 b2 = new JButton("多賬號"); b2.setBounds(5, 200, 75, 20); //設(shè)置 b3 = new JButton("設(shè)置"); b3.setBounds(100, 200, 65, 20); //所有組件用容器裝載 j1.add(j2); j1.add(j3); j1.add(j4); j1.add(c1); j1.add(c2); j1.add(cb1); j1.add(b1); j1.add(b2); j1.add(b3); container.add(j1); container.add(ulName); container.add(ulPasswd); } public static void main(String[] args) { new QQ(); } }

運(yùn)行結(jié)果界面為:
對于新手小白想更輕松的學(xué)好Java提升,Java架構(gòu),web開發(fā)、大數(shù)據(jù),數(shù)據(jù)分析,人工智能等技術(shù),這里給大家分享系統(tǒng)教學(xué)資源,擴(kuò)列下我尉(同英):1253431195【教程/工具/方法/解疑】

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持。

總結(jié)

以上是生活随笔為你收集整理的java实现简单QQ登录界面的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。