導航:首頁 > 編程語言 > java做的qq

java做的qq

發布時間:2024-10-31 22:10:11

㈠ 用java怎麼寫QQ

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

㈡ 用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);

}

});

}
}

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

}

}

閱讀全文

與java做的qq相關的資料

熱點內容
java工程師在深圳 瀏覽:656
手機sql編譯軟體 瀏覽:524
外網伺服器地址購買 瀏覽:994
空調壓縮機電容價格 瀏覽:381
小程序選什麼雲伺服器 瀏覽:656
如何把java編譯回中文 瀏覽:777
天聯軟體伺服器地址是什麼 瀏覽:964
stc單片機加密 瀏覽:140
小程序地產廣告源碼 瀏覽:542
消費者信息加密私域 瀏覽:431
程序員開發團隊可以怎麼創業 瀏覽:925
設備共享伺服器是什麼意思 瀏覽:126
java符號類型 瀏覽:331
redis客戶端java 瀏覽:214
javatn 瀏覽:278
應用寶哪裡下載王卡免流量app 瀏覽:235
uv7代噴頭加密與不加密 瀏覽:467
滾動指標源碼查詢 瀏覽:986
夢幻西遊lua源碼修改教程 瀏覽:937
androidphp環境 瀏覽:762