java的qq程序代碼 java實現(xiàn)

有誰知道QQ后臺程序用JAVA怎么編寫啊?

import java.io.*;

成都創(chuàng)新互聯(lián)公司2013年至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都做網(wǎng)站、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元輪臺做網(wǎng)站,已為上家服務(wù),為輪臺各地企業(yè)和個人服務(wù),聯(lián)系電話:028-86922220

public class QQ_Manager {

private int max_user=1000;

private String[] userID;

private String[] userName;

private String[] userPW;

private String[] userIP;

private int userCounts;

private int userOnline;

private String fileName;

/**構(gòu)造方法初始化數(shù)據(jù)文件等*/

QQ_Manager(String fileName){this.fileName=fileName;}

/**將現(xiàn)有的QQ用戶和記錄寫入數(shù)據(jù)文件*/

public synchronized void write_userDataFile(String fileName) {

}

/**從數(shù)據(jù)文件中讀取QQ用戶記錄*/

public synchronized void read_userDataFile(String fileName) {

}

/**用戶來注冊新的QQ號*/

public synchronized boolean regist_QQ(String userName,String PW){return false;}

/**QQ用戶登陸處理*/

public synchronized boolean login_QQ(String id,String pw){return true;}

/**QQ用戶離線處理*/

public synchronized boolean logout_QQ(String id, String pw){return false;}

/**返回QQ在線列表*/

public String get_QQList(){return null;}

}

用JAVA怎么寫QQ

用java是可以寫出qq的,只不過用java開發(fā)c/s的軟件不是java特長的,你要是真的想寫,就寫著練練手吧,最起碼可以鞏固java se上的知識。

具體怎么寫,給你個大概的思路吧,因為我沒辦法在這個有限的輸入框內(nèi)把所有的代碼寫完。

【1】先寫出qq的簡單界面

【2】給每個按鈕添加監(jiān)聽

【3】按鈕事件(方法)定義

【4】連接網(wǎng)絡(luò)(socket)

【5】測試

【5】其他功能添加

【6】測試

用java怎么實現(xiàn)QQ登錄界面?

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

package ch10;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

1、//定義該類繼承自JFrame,實現(xiàn)ActionListener接口

public class LoginTest extends JFrame implements ActionListener

{

2、//創(chuàng)建JPanel對象

private JPanel jp=new JPanel();

3、//創(chuàng)建3個標(biāo)并加入數(shù)組

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

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

JLabel show = new JLabel("");

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

4、//創(chuàng)建登陸和重置按扭并加入數(shù)組

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

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

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

5、//創(chuàng)建文本框以及密碼框

private JTextField jName=new JTextField();

private JPasswordField jPassword =new JPasswordField();

public LoginTest()

{

6、//設(shè)置布局管理器為空布局,這里自己擺放按鈕、標(biāo)簽和文本框

jp.setLayout(null);

for(int i=0;i2;i++)

{

7、//設(shè)置標(biāo)簽和按扭的位置與大小

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

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

8、//添加標(biāo)簽和按扭到JPanel容器中

jp.add(jl[i]);

jp.add(jb[i]);

//為2個按鈕注冊動作事件監(jiān)聽器

jb[i].addActionListener(this);

}

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

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

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

jp.add(jName);

11、//為文本框注冊動作事件監(jiān)聽器

jName.addActionListener(this);

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

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

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

jp.add(jPassword);

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

jPassword.setEchoChar('$');

15、//為密碼框注冊動作事件監(jiān)聽器

jPassword.addActionListener(this);

16、//設(shè)置用于顯示登陸狀態(tài)的標(biāo)簽大小位置,并將其添加進(jìn)JPanel容器

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

jp.add(jl[2]);

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

this.add(jp);

18、//設(shè)置窗體的標(biāo)題、位置、大小、可見性及關(guān)閉動作

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

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

this.setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

19、//實現(xiàn)動作監(jiān)聽器接口中的方法actionPerformed

public void actionPerformed(ActionEvent e)

{

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

if(e.getSource()==jName)

{

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

jPassword.requestFocus();

}

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

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

{

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

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、//創(chuàng)建LoginTest窗體對象

new LoginTest();

}

}

JAVA 用代碼實現(xiàn)登入QQ空間操作

遼主臨軒的分享

分享

java程序模擬qq登錄界面的代碼

java程序如何實現(xiàn)登錄、記住密碼、自動登錄等功能!

package dyno.swing.beans.qq;

import javax.swing.*;

import javax.swing.event.MouseInputListener;

import org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel;

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

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

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點虐 .Socket;

import java點虐 .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,shezhi,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 (UnsupportedLookAndFeelException 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);//設(shè)置進(jìn)度欄的最大值

activity=new SimThread(1000);

activity.start();//啟動線程

activityMonitor.start();//啟動定時器

chashamuma.setEnabled(false);//禁止按鈕

}

});

activityMonitor=new Timer(100,new ActionListener(){//每0.5秒執(zhí)行一次

public void actionPerformed(ActionEvent e){//以下動作將在事件調(diào)度線程中運行,十分安全

int current=activity.getCurrent();//得到線程的當(dāng)前進(jìn)度

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

if(current==activity.getTarget()){//如果到達(dá)目標(biāo)值

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("baijiantou.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.setDefaultLookAndFeelDecorated(true);

try {

UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel()) ;

UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel");

} 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;//進(jìn)度欄的當(dāng)前值

private int target;//進(jìn)度欄的最大值

public SimThread(int t){

current=0;

target=t;

}

public int getTarget(){

return target;

}

public int getCurrent(){

return current;

}

public void run(){//線程體

try{

while (currenttarget !interrupted()){//如果進(jìn)度欄的當(dāng)前值小于目標(biāo)值并且線程沒有被中斷

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();

}

}

網(wǎng)頁題目:java的qq程序代碼 java實現(xiàn)
文章地址:http://www.bm7419.com/article46/ddehjeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計公司微信公眾號、網(wǎng)站導(dǎo)航網(wǎng)頁設(shè)計公司、定制開發(fā)、動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)