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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java仿qq gui_Java仿QQ登入页面

發布時間:2025/3/8 java 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java仿qq gui_Java仿QQ登入页面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.[代碼][Java]代碼

package com.myqq.frame;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Cursor;

import java.awt.FlowLayout;

import java.awt.Font;

import java.awt.GridLayout;

import java.awt.Image;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.io.IOException;

import java.util.Properties;

import javax.swing.*;

import javax.swing.border.TitledBorder;

import com.myqq.action.LoginAction;

public class LoginFrame extends JFrame{

private JLabel backImg;//背景

private JLabel label_1;

private JLabel label_2;

private JTextField userName;//用戶名

private JPasswordField pwd;//密碼

private JCheckBox recardPwd;//記住密碼

private JLabel label_3;

private JCheckBox autoLogin;//自動登入

private JLabel label_4;

private JLabel newUser;

private JLabel findPwd;

private JButton login;//登入

private JButton setting; //關閉

private JPanel panel;

private JPanel loginPanel;

private JPanel pwdPanel;

private JPanel checkPanel;

private JPanel centerPanel;

private JPanel btn_Panel;

public JTextField getUserName() {

return userName;

}

public void setUserName(JTextField userName) {

this.userName = userName;

}

public JPasswordField getPwd() {

return pwd;

}

public void setPwd(JPasswordField pwd) {

this.pwd = pwd;

}

public LoginFrame()

{

super("MY QQ");

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

initGUI();

}

/**

* 初始化界面

*/

private void initGUI()

{

// Image toolimage = new ImageIcon(getClass().getClassLoader().getResource("images/Face2/0.gif")).getImage();

// setIconImage(toolimage);

panel = new JPanel();

//panel.setBackground(Color.WHITE);

panel.setLayout(new BorderLayout());

backImg = new JLabel();

ImageIcon image = new ImageIcon(getClass().getClassLoader().getResource("images/backImg.jpg"));

backImg.setIcon(image);

panel.add(backImg,"North");

//panel.setLayout(new GridLayout(3,0));

label_1 = new JLabel("用戶帳號:");

setFonts(label_1);

label_2 = new JLabel("用戶密碼:");

setFonts(label_2);

userName = new JTextField(12);

pwd = new JPasswordField(12);

loginPanel = new JPanel();

loginPanel.add(label_1);

loginPanel.add(userName);

newUser = new JLabel("新用戶注冊");

newUser.addMouseListener(new MouseAdapter() {

public void mousePressed(MouseEvent e) {

Properties properties = System.getProperties();

String s = properties.getProperty("os.name");

System.out.println((new StringBuilder()).append("當前的操作系統名稱: ").append(s).toString());

if (s.indexOf("LINUX") != -1)

try {

Runtime.getRuntime().exec("HTMLview http://www.qq.com");

} catch (IOException e1) {

e1.printStackTrace();

}

else

if (s.indexOf("Windows") != -1)

{

try {

Runtime.getRuntime().exec("explorer http://www.qq.com");

} catch (IOException e1) {

e1.printStackTrace();

}

} else

{

JOptionPane.showMessageDialog(LoginFrame.this, "未知操作系統");

System.out.println((new StringBuilder()).append("未知的操作系統: ").append(s).toString());

throw new RuntimeException("Unknown OS.");

}

}

});

newUser.setCursor(new Cursor(Cursor.HAND_CURSOR));

newUser.setForeground(Color.blue);

setFonts(newUser);

loginPanel.add(newUser);

loginPanel.setBackground(Color.WHITE);

pwdPanel = new JPanel();

pwdPanel.add(label_2);

pwdPanel.add(pwd);

findPwd = new JLabel("找回密碼 ");

findPwd.setCursor(new Cursor(Cursor.HAND_CURSOR));

findPwd.setForeground(Color.blue);

setFonts(findPwd);

pwdPanel.add(findPwd);

pwdPanel.setBackground(Color.WHITE);

checkPanel = new JPanel();

recardPwd = new JCheckBox();

recardPwd.setBackground(Color.white);

label_3 = new JLabel("記住密碼");

setFonts(label_3);

autoLogin = new JCheckBox();

autoLogin.setBackground(Color.white);

label_4 = new JLabel("自動登入");

setFonts(label_4);

checkPanel.add(recardPwd);

checkPanel.add(label_3);

checkPanel.add(autoLogin);

checkPanel.add(label_4);

checkPanel.setBackground(Color.WHITE);

centerPanel = new JPanel();

centerPanel.setBackground(Color.WHITE);

centerPanel.setBorder(new TitledBorder(""));

centerPanel.setLayout(new GridLayout(3,0));

centerPanel.add(loginPanel);

centerPanel.add(pwdPanel);

centerPanel.add(checkPanel);

btn_Panel = new JPanel();

//btn_Panel.setLayout(new FlowLayout(FlowLayout.CENTER,15,0));

login = new JButton("登入");

login.addActionListener(new LoginAction(this));

setFonts(login);

setting = new JButton("設置");

setFonts(setting);

btn_Panel.add(login);

btn_Panel.add(setting);

btn_Panel.setBackground(new Color(235,243,249));

panel.add(centerPanel);

panel.add(btn_Panel,"South");

add(panel);

}

/*

* 設置字體

*/

private void setFonts(JComponent c)

{

c.setFont(new Font("微軟雅黑",Font.PLAIN,12));

}

}



總結

以上是生活随笔為你收集整理的java仿qq gui_Java仿QQ登入页面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。