當前位置:首頁 » 編程語言 » java編寫qq

java編寫qq

發布時間: 2025-02-20 02:52:10

A. qq聊天界面怎麼寫啊,用java語言寫

愛應用團隊為你解答
網路資料
package cn.myself.myproject.FrameProject;import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;import javax.swing.Icon;
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.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;import cn.myself.myproject.employeepj.view.common.CenterWindow;
/**
* 程序功能:QQ登陸面板
* 學習內容:GridBagLayout布局方式的學習
* 以GridBagLayout方式布局的容器,其容器中的每個組件必須由一個GridBagConstrains類的實例對象進行大小,位置等約束。
* @author huliu 2009-06-26
* 難題:a.帳號後面是什麼框?
* b.圖片的相對路徑怎麼設置?
*/
public class QQRegistBoard extends JFrame{
JPanel p1;
GridBagLayout gb1;
GridBagConstraints gbc1;
JButton btn1,btn2;
JLabel label0,label1,label2,label3,label4,label5;
JTextField text1,text2;
JComboBox box1,box2;
JCheckBox check1,check2;
JList list1;
/**
* 構造方法
*/
public QQRegistBoard(){
super("2009正式版(huliu)");
p1=new JPanel();
gb1=new GridBagLayout();
gbc1=new GridBagConstraints();
p1.setLayout(gb1);//GridBagLayout布局。網袋布局
getContentPane().add(p1); //取得當前容器對象
this.setSize(350,250);
CenterWindow.centerW(this);
Icon icon1 = new ImageIcon("./QQ2.jpg");
// Icon icon1 = new ImageIcon("./QQ.jpg"); //載入圖片,當前目錄下的QQ.jpg
// Icon icon1 = new ImageIcon("src/cn/mysef/images/QQ1.jpg");
label0=new JLabel(icon1);
label1=new JLabel("帳號:");
label2=new JLabel("注冊新帳號");
label3=new JLabel("密碼:");
label4=new JLabel("取回密碼");
label5=new JLabel("狀態:");
text1=new JTextField(10);
text2=new JTextField(10);
String[] str1={"313558851","313857401","690442763"};
box1=new JComboBox(str1);
box1.setEditable(true);//設置ComboBox欄位值是否為可編輯
box2=new JComboBox();
check1=new JCheckBox("記住密碼",true);
check2=new JCheckBox("自動登錄");
btn1=new JButton("設置");
btn2=new JButton("登錄");

p1.add(label0,GBC(0,0,3,1,new Insets(5,2,2,4)));//圖片
p1.add(label1,GBC(1,0,1,1,new Insets(4,2,2,4)));
p1.add(box1, GBC(1,1,1,1,new Insets(4,2,2,0)));
//p1.add(text2,GBC(1,1,1,1));
p1.add(label2,GBC(1,2,1,1,new Insets(4,2,2,3)));
p1.add(label3,GBC(2,0,1,1,new Insets(4,2,2,3)));
p1.add(text1, GBC(2,1,1,1,new Insets(5,2,2,3)));
p1.add(label4,GBC(2,2,1,1,new Insets(4,2,2,3)));
p1.add(label5,GBC(3,0,1,1,new Insets(4,2,2,3)));
p1.add(check1,GBC(3,1,1,1,new Insets(4,2,2,3)));
p1.add(check2,GBC(3,2,1,1,new Insets(4,2,2,3)));
p1.add(btn1 ,GBC(4,0,1,1,new Insets(4,2,2,3)));
p1.add(btn2 ,GBC(4,2,1,1,new Insets(4,2,2,3)));
}
/**
* GBC方法:功能是設計以GridBagLayout方式布局的容器(如Panel容器對象)內的組件的位置,大小等約束的。
* @param gridy
* @param gridx
* @param gridwidth
* @param gridheight
* @return GridBagStraints實對象
* Insets(int top, int left, int bottom, int right),與其它組件之間距離(上,左,下,右)
*/
public GridBagConstraints GBC(int gridy,int gridx,int gridwidth,int gridheight,Insets insets){
GridBagConstraints gbc1=new GridBagConstraints();
gbc1.gridx=gridx; //列
gbc1.gridy=gridy; //行
gbc1.gridwidth=gridwidth;//寬度
gbc1.gridheight=gridheight; //高度
//insets=new Insets(1,1,1,1);
gbc1.insets=insets;
return gbc1;
}
public static void main(String[] args){
new QQRegistBoard().setVisible(true);
}}
望採納

B. 用java怎麼實現QQ登錄界面

用java做QQ登錄界面的寫法如下:

package ch10;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

1、//定義該類繼承自JFrame,實現ActionListener介面

public class LoginTest extends JFrame implements ActionListener

{

2、//創建JPanel對象

private JPanel jp=new JPanel();

3、//創建3個標並加入數組

JLabel name = new JLabel("請輸入用戶名");

JLabel password = new JLabel("請輸入密碼");

JLabel show = new JLabel("");

private JLabel[] jl={name,password,show};

4、//創建登陸和重置按扭並加入數組

JButton login = new JButton("登陸");

JButton reset = new JButton("重置");

private JButton[] jb={login,reset};

5、//創建文本框以及密碼框

private JTextField jName=new JTextField();

private JPasswordField jPassword =new JPasswordField();

public LoginTest()

{

6、//設置布局管理器為空布局,這里自己擺放按鈕、標簽和文本框

jp.setLayout(null);

for(int i=0;i<2;i++)

{

7、//設置標簽和按扭的位置與大小

jl[i].setBounds(30,20+40*i,180,20);

jb[i].setBounds(30+110*i,100,80,20);

8、//添加標簽和按扭到JPanel容器中

jp.add(jl[i]);

jp.add(jb[i]);

//為2個按鈕注冊動作事件監聽器

jb[i].addActionListener(this);

}

9、//設置文本框的位置和大小,注意滿足美觀並足夠用戶名的長度

jName.setBounds(130,15,100,20);

10、//添加文本框到JPanel容器中

jp.add(jName);

11、//為文本框注冊動作事件監聽器

jName.addActionListener(this);

12、//設置密碼框的位置和大小,注意滿足美觀和足夠密碼的長度

jPassword.setBounds(130,60,100,20);

13、//添加密碼框到JPanel容器中

jp.add(jPassword);

14、//設置密碼框中的回顯字元,這里設置美元符號

jPassword.setEchoChar('$');

15、//為密碼框注冊動作事件監聽器

jPassword.addActionListener(this);

16、//設置用於顯示登陸狀態的標簽大小位置,並將其添加進JPanel容器

jl[2].setBounds(10,180,270,20);

jp.add(jl[2]);

17、//添加JPanel容器到窗體中

this.add(jp);

18、//設置窗體的標題、位置、大小、可見性及關閉動作

this.setTitle("登陸窗口");

this.setBounds(200,200,270,250);

this.setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

19、//實現動作監聽器介面中的方法actionPerformed

public void actionPerformed(ActionEvent e)

{

20、//如果事件源為文本框

if(e.getSource()==jName)

{

21、//切換輸入焦點到密碼框

jPassword.requestFocus();

}

22、//如果事件源為重置按扭

else if(e.getSource()==jb[1])

{

23、//清空姓名文本框、密碼框和show標簽中的所有信息

jl[2].setText("");

jName.setText("");

jPassword.setText("");

24、//讓輸入焦點回到文本框

jName.requestFocus();

}

25、//如果事件源為登陸按鈕,則判斷登錄名和密碼是否正確

else

{

26、//判斷用戶名和密碼是否匹配

if(jName.getText().equals("lixiangguo")&&

String.valueOf(jPassword.getPassword()).equals("19801001"))

{

27、jl[2].setText("登陸成功,歡迎您的到來!");

}

else

{

28、jl[2].setText("對不起,您的用戶名或密碼錯誤!");

}

}

}

public static void main(String[] args)

{

29、//創建LoginTest窗體對象

new LoginTest();

}

}

C. 求QQ登陸界面的Java GUI(圖形用戶界面開發)代碼!

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;

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.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class Demo extends JFrame{

Container contentPane;
ImageIcon img = new ImageIcon("002.jpg");

JPanel paneTop = new JPanel();
JPanel paneMid = new JPanel();
JPanel paneBut = new JPanel();
JPanel paneAll = new JPanel();

JLabel lblTop = new JLabel();
JLabel lblName = new JLabel();
JLabel lblPwd = new JLabel();
JLabel lblApply = new JLabel();
JLabel lblForget = new JLabel();
JLabel lblModel = new JLabel();
JLabel lblNull = new JLabel();

JTextField txtName = new JTextField(15);
JPasswordField txtPwd = new JPasswordField(15);

JComboBox cmb = new JComboBox();

JCheckBox chk = new JCheckBox();

JButton btnKill = new JButton("查殺木馬");
JButton btnSet = new JButton("設置");
JButton btnLogin = new JButton("登錄");

Demo(){
lblTop.setIcon(img);
paneTop.add(lblTop);

lblName.setText("QQ帳號:");
lblApply.setText("申請帳號 ");
lblPwd.setText("QQ密碼:");
lblForget.setText("忘記密碼?");
lblModel.setText("狀態:");

String[] s1 = {"隱身","在線","忙碌"};
cmb.addItem(s1[0]);
cmb.addItem(s1[1]);
cmb.addItem(s1[2]);

chk.setText("自動登錄");

paneMid.add(lblName);
paneMid.add(txtName);
paneMid.add(lblApply);

paneMid.add(lblPwd);
paneMid.add(txtPwd);
paneMid.add(lblForget);

paneMid.add(lblModel);
paneMid.add(cmb);
paneMid.add(chk);

paneBut.add(btnKill);
paneBut.add(btnSet);
paneBut.add(btnLogin);

contentPane = this.getContentPane();

contentPane.add(paneTop,BorderLayout.NORTH);
contentPane.add(paneMid,BorderLayout.CENTER);
contentPane.add(paneBut,BorderLayout.SOUTH);

setTitle("歡迎使用QQ");
setSize(330,240);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width - getSize().width)/2,(screen.height - getSize().height)/2 );
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String args[]){
Demo d = new Demo();
}

}

D. 用JAVA怎麼寫QQ

用java是可以寫出qq的,只不過用java開發c/s的軟體不是java特長的,你要是真的想寫,就寫著練練手吧,最起碼可以鞏固java se上的知識。
具體怎麼寫,給你個大概的思路吧,因為我沒辦法在這個有限的輸入框內把所有的代碼寫完。
【1】先寫出qq的簡單界面
【2】給每個按鈕添加監聽
【3】按鈕事件(方法)定義
【4】連接網路(socket)
【5】測試
【5】其他功能添加
【6】測試

E. 用java做QQ界面的框架代碼

我有個現成的你看看

package dyno.swing.beans.qq;

import javax.swing.*;
import javax.swing.event.MouseInputListener;

import org.jvnet.substance.skin.;
/*import org.jvnet.substance.skin.SubstanceModerateLookAndFeel;
import org.jvnet.substance.skin.;*/

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

public class QQLogin extends JFrame implements MouseInputListener,ActionListener{
JLabel guanggao,beijing,wenzi,she,zhanghaowb,qq1,dengluzhuangtai;
// JTextField zhanghao;

JPopupMenu haoma;
JComboBox zhanghao;
JPasswordField mima;
JCheckBox jizhumima,zidongdenglu;
JButton denglu,chashamuma;
JProgressBar jpb;
SimThread activity;
Timer activityMonitor;
String name,qq;
Socket s;
public QQLogin()
{
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException e1) {
// TODO 自動生成 catch 塊
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO 自動生成 catch 塊
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO 自動生成 catch 塊
e1.printStackTrace();
} catch ( e1) {
// TODO 自動生成 catch 塊
e1.printStackTrace();
}
chashamuma = new JButton("查殺木馬");
chashamuma.setBounds(240, 155,85, 20);
this.add(chashamuma);
jpb = new JProgressBar();
jpb.setStringPainted(true);
jpb.setBounds(100, 240, 200, 15);
this.add(jpb);
chashamuma.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

jpb.setMaximum(1000);//設置進度欄的最大值
activity=new SimThread(1000);
activity.start();//啟動線程
activityMonitor.start();//啟動定時器
chashamuma.setEnabled(false);//禁止按鈕
}
});
activityMonitor=new Timer(100,new ActionListener(){//每0.5秒執行一次
public void actionPerformed(ActionEvent e){//以下動作將在事件調度線程中運行,十分安全

int current=activity.getCurrent();//得到線程的當前進度

jpb.setValue(current);//更新進度欄的值

if(current==activity.getTarget()){//如果到達目標值
activityMonitor.stop();//終止定時器
chashamuma.setEnabled(true);//激活按鈕
}
}
});
dengluzhuangtai = new JLabel(new ImageIcon("zaixianzhuangtai.jpg"));
dengluzhuangtai.setBounds(75, 145, 35, 30);
this.add(dengluzhuangtai);
dengluzhuangtai.addMouseListener(this);
denglu = new JButton("登錄");
denglu.setBounds(140, 155, 80, 20);
this.add(denglu);
this.setAlwaysOnTop(true);
zidongdenglu = new JCheckBox("自動登錄");
zidongdenglu.setBounds(200, 190, 100, 30);
this.add(zidongdenglu);
jizhumima = new JCheckBox("記住密碼");
jizhumima.setBounds(100, 190, 100, 30);
// jizhumima.setBackground(new Color(228, 244, 255));
this.add(jizhumima);

haoma = new JPopupMenu();

/* zhanghao = new JTextField(20);
zhanghao.setBounds(120, 78, 135, 20);
zhanghao.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.WHITE));
zhanghao.setFont(new Font("宋體",Font.PLAIN,13));
this.add(zhanghao);*/
// zhanghaowb = new JLabel(new ImageIcon("2.png"));
// zhanghaowb.setBounds(90, 73, 194, 31);
// jiantou = new JLabel(new ImageIcon("jiantou.png"));
// jiantou.setBounds(256, 78, 23, 21);
// jiantou.addMouseListener(this);
// this.add(jiantou);
// this.add(zhanghaowb);
chashamuma.addActionListener(this);
mima = new JPasswordField();
mima.setEchoChar('*');
mima.setFont(new Font("宋體",Font.PLAIN,13));
mima.setBounds(100, 113, 150, 20);
this.add(mima);

zhanghao = new JComboBox();
zhanghao.setEditable(true);
zhanghao.setBounds(100, 78, 150, 20);
zhanghao.setFont(new Font("宋體",Font.PLAIN,13));
this.add(zhanghao);
guanggao = new JLabel(new ImageIcon("guanggao.gif"));
guanggao.setBounds(0, 0, 334, 64);
beijing = new JLabel(new ImageIcon("beijing.jpg"));
beijing.setBounds(0, 64, 334, 154);
wenzi = new JLabel(new ImageIcon("wenzi.jpg"));
wenzi.setBounds(30, 75, 50, 100);

denglu.addActionListener(this);
// zhanghaowb.addMouseListener(this);
// zhanghao.addMouseListener(this);
this.add(wenzi);
this.add(beijing);
this.setLayout(null);
this.add(guanggao);
this.setVisible(true);
this.setDefaultCloseOperation(3);
this.setSize(340, 250);
this.setLocationRelativeTo(null);
}
public static void main(String[] args) {
/*JFrame.(true);
try {
UIManager.setLookAndFeel(new ()) ;
UIManager.setLookAndFeel("org.jvnet.substance.skin.");

} catch (Exception e) {
System.out.println("Substance Raven Graphite failed to initialize");
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
QQLogin w = new QQLogin();
w.setVisible(true);
}
});*/
new QQLogin();
}
public void mouseClicked(MouseEvent e) {
// TODO 自動生成方法存根

}
public void mouseEntered(MouseEvent e) {
if(e.getSource() == dengluzhuangtai)
{
dengluzhuangtai.setIcon(new ImageIcon("zaixianzhuangtaidian.jpg"));
}

}
public void mouseExited(MouseEvent e) {
if(e.getSource() == dengluzhuangtai)
{
dengluzhuangtai.setIcon(new ImageIcon("zaixianzhuangtai.jpg"));

}

}
public void mousePressed(MouseEvent e) {
// TODO 自動生成方法存根

}
public void mouseReleased(MouseEvent e) {
// TODO 自動生成方法存根

}
public void mouseDragged(MouseEvent e) {
// TODO 自動生成方法存根

}
public void mouseMoved(MouseEvent e) {
// TODO 自動生成方法存根

}
public class liaotianchuangkou
{

}
class SimThread extends Thread{//線程類
private int current;//進度欄的當前值
private int target;//進度欄的最大值

public SimThread(int t){
current=0;
target=t;
}

public int getTarget(){
return target;
}

public int getCurrent(){
return current;
}

public void run(){//線程體
try{
while (current<target && !interrupted()){//如果進度欄的當前值小於目標值並且線程沒有被中斷
sleep(10);
current++;
if(current == 700)
{
sleep(3000);
}
else if(current == 730)
{
sleep(1000);
}
}
}catch (InterruptedException e){}
}

}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == chashamuma)
{
this.setBounds(300, 300, 340, 300);
}
else if(e.getSource() == denglu)
{
String zh = (String) zhanghao.getSelectedItem();
System.out.println(zhanghao.getSelectedItem());
// System.out.println(zhanghao.getItemAt(0));
char [] str = mima.getPassword();
String mima = String.valueOf(str);;
System.out.println(mima);
// Sql login = new Sql();

// if(login.login(zh,mima))
// {
try {
s = new Socket("127.0.0.1",8888);
System.out.println(s);
PrintWriter pw;
Scanner sc;
pw = new PrintWriter(s.getOutputStream(),true);
sc = new Scanner(s.getInputStream());
String str2 = "login#289872400198724#"+zh+"#289872400198724#"+mima;
System.out.println(str2);
pw.println(str2);

String str3 = sc.nextLine();
String yanzheng[] = str3.split("#");
System.out.println(str3);
if(yanzheng[0].equals("true"))
{
System.out.println("登陸成功!");
name = yanzheng[1];
qq = yanzheng[2];

// this.setVisible(false);

// Thread.sleep(5000);
System.out.println("woao"+name);
System.out.println("woai"+qq);

Logined logined = new Logined(name,qq);
this.setVisible(false);

}
else
{
JOptionPane.showMessageDialog(this, "用戶名或密碼錯誤!", "用戶名或密碼錯誤!", 0);
}

} catch (UnknownHostException e2) {
// TODO 自動生成 catch 塊
e2.printStackTrace();
} catch (IOException e2) {
// TODO 自動生成 catch 塊
e2.printStackTrace();
}

/*try {
login.rs = login.stat.executeQuery("select * from qquser where username='"+zh+"' and password = '"+mima+"'");
boolean flag = login.rs.next();
if(flag == true)
{
name = login.rs.getString("name");
qq = login.rs.getString("username");
}
else
{

}*/

// } catch (SQLException e1) {
// TODO 自動生成 catch 塊
// e1.printStackTrace();
// }

}
else
{
JOptionPane.showMessageDialog(this, "用戶名或密碼錯誤", "輸入錯誤", 0);
}
// this.setVisible(false);
//new Logined();

}

}

F. 用java製作qq登錄界面,只要界面,不要事件處理

package ibees.qq;

import java.awt.BorderLayout;
import java.net.URL;

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.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
* 仿QQ登錄界面,僅供學習參考,涉及到的有窗口居中、JPanel、LayoutManager的使用
* @author hhzxj2008
* */
public class QQLoginView extends JFrame {

/**
*
*/
private static final long serialVersionUID = -5665975170821790753L;

public QQLoginView() {
initComponent();
}

private void initComponent() {
setTitle("用戶登錄");
//設置LOGO
URL image = QQLoginView.class.getClassLoader().getResource("ibees/qq/images/year.jpg");//圖片的位置
JLabel imageLogo = new JLabel(new ImageIcon(image));
add(imageLogo,BorderLayout.NORTH);

//QQ號和密碼
JPanel jp = new JPanel();
JPanel jpAccount = new JPanel();
jpAccount.add(new JLabel("帳號"));
JTextField userTextField = new JTextField(15);
jpAccount.add(userTextField);
jpAccount.add(new JLabel("用戶注冊"));
jp.add(jpAccount);

JPanel jpPass = new JPanel();
jpPass.add(new JLabel("密碼"));
JPasswordField passTextField = new JPasswordField(15);
jpPass.add(passTextField);
jpPass.add(new JLabel("找回密碼"));
jp.add(jpPass);

//登錄設置
JPanel jpstatus = new JPanel();
jpstatus.add(new JLabel("狀態"));
JComboBox statusComboBox = new JComboBox();
statusComboBox.addItem("Q我");
statusComboBox.addItem("在線");
statusComboBox.addItem("隱身");
statusComboBox.addItem("離線");
jpstatus.add(statusComboBox);
jpstatus.add(new JCheckBox("記住密碼"));
jpstatus.add(new JCheckBox("自動登錄"));
jp.add(jpstatus);
add(jp);

//底部登錄按鈕
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new BorderLayout());
bottomPanel.add(new JButton("設置"),BorderLayout.WEST);
bottomPanel.add(new JButton("登錄"),BorderLayout.EAST);
add(bottomPanel,BorderLayout.SOUTH);
setSize(324,230);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}

/**
* @param args
*/
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable(){

@Override
public void run() {
new QQLoginView().setVisible(true);

}

});

}
}

熱點內容
編程用的系統 發布:2025-02-21 17:12:37 瀏覽:647
亞索最新腳本 發布:2025-02-21 17:11:07 瀏覽:426
java獲取本周 發布:2025-02-21 16:55:35 瀏覽:358
怎麼去掉同步伺服器地址 發布:2025-02-21 16:46:56 瀏覽:237
加密安卓 發布:2025-02-21 16:11:54 瀏覽:73
張軍編程 發布:2025-02-21 16:11:47 瀏覽:958
網站伺服器埠如何查看 發布:2025-02-21 16:11:00 瀏覽:408
光遇什麼安卓手機畫質最好 發布:2025-02-21 16:07:40 瀏覽:334
怎麼知道qq號密碼忘了怎麼辦啊 發布:2025-02-21 15:53:36 瀏覽:554
oracle創建的視圖帶有編譯錯誤 發布:2025-02-21 15:52:19 瀏覽:780