導航:首頁 > 編程語言 > qqjava介面開發

qqjava介面開發

發布時間:2024-04-11 08:53:10

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

}

}

❷ 怎麼用java打開qq

java實現簡單QQ登陸界面:
1.生成界面的java代碼
packageQQ2014;
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;
publicclassQQ2014{
//創建登陸界面類
publicvoidshowLoginFrame(){
//創建船體對象
JFrameloginFrame=newJFrame();
//設置大小,位置,標題
loginFrame.setSize(300,200);
loginFrame.setTitle("QQ2014");
loginFrame.setLocationRelativeTo(null);
//創建流式分布對象
FlowLayoutlayout=newFlowLayout();
loginFrame.setLayout(layout);
//創建賬戶名,密碼和輸入框
JLabeluser_name=newJLabel("賬號:");
JLabeluser_password=newJLabel("密碼:");
JTextFieldfield_name=newJTextField(20);
JPasswordFieldfield_password=newJPasswordField(20);
//創建登陸,重置按鈕
JButtonbutton_reset=newJButton("重置");
JButtonbutton_login=newJButton("登陸");
//設置窗體可見
loginFrame.setVisible(true);
//創建事件監聽對象
ActionListeneraction_listener1=newActionListener(){
publicvoidactionPerformed(ActionEvente){
Stringname=field_name.getText();
Stringpassword=field_password.getText();
if("zhaoxin".equals(name)&&"123".equals(password))
{
showIndexFrame();
loginFrame.setDefaultCloseOperation(3);
loginFrame.setVisible(false);
}
else{
System.out.println("密碼錯誤,重新輸入!");
}
}
};
ActionListeneraction_listener2=newActionListener(){
publicvoidactionPerformed(ActionEvente){
field_name.setText("");
field_password.setText("");
}
};
//將文本輸入框,按鈕,事件監聽對象添加
loginFrame.add(user_name);
loginFrame.add(field_name);
loginFrame.add(user_password);
loginFrame.add(field_password);
loginFrame.add(button_reset);
loginFrame.add(button_login);
button_reset.addActionListener(action_listener2);
button_login.addActionListener(action_listener1);
}
publicvoidshowIndexFrame(){
//創建窗體對象
JFrameindexFrame=newJFrame();
indexFrame.setSize(200,500);
indexFrame.setTitle("QQ好友列表");
indexFrame.setLocationRelativeTo(null);
//設置流式分布對象
FlowLayoutlayout=newFlowLayout(FlowLayout.CENTER,100,10);
indexFrame.setLayout(layout);
//創建好友按鈕
for(inti=0;i<10;i++)
{
JButtonbutton_friend=newJButton("friend"+i);
//創建動作事件監聽對象
ActionListeneraction_listener=newActionListener()
{
publicvoidactionPerformed(ActionEvente)
{
showChatFrame();
indexFrame.setVisible(false);
indexFrame.setDefaultCloseOperation(3);
}
};
button_friend.addActionListener(action_listener);
indexFrame.add(button_friend);
}
//設置窗體可見
indexFrame.setVisible(true);
}
publicvoidshowChatFrame(){
//創建窗體,大小,位置,標題
JFramechatFrame=newJFrame();
chatFrame.setSize(400,400);
chatFrame.setTitle("正在聊天中...");
chatFrame.setLocationRelativeTo(null);
//創建聊天記錄,輸入域
JTextAreaarea_input=newJTextArea(10,30);
JTextAreaarea_record=newJTextArea(5,30);
//創建流式分布對象
FlowLayoutlayout=newFlowLayout(FlowLayout.CENTER,0,10);
chatFrame.setLayout(layout);
//創建發送,關閉按扭
JButtonbutton_send=newJButton("發送");
JButtonbutton_close=newJButton("關閉");
//創建動作事件監聽對象
ActionListeneraction_listener1=newActionListener()
{
publicvoidactionPerformed(ActionEvente){
area_record.setText(area_record.getText()+" "+area_input.getText());
area_input.setText("");
}
};
ActionListeneraction_listener2=newActionListener()
{
publicvoidactionPerformed(ActionEvente){
chatFrame.setVisible(false);
chatFrame.setDefaultCloseOperation(3);
}
};
//設置窗體可見
chatFrame.setVisible(true);
//添加按鈕,事件監聽對象
chatFrame.add(area_record);
chatFrame.add(area_input);
chatFrame.add(button_send);
chatFrame.add(button_close);
button_send.addActionListener(action_listener1);
button_close.addActionListener(action_listener2);
}
}
復制代碼
2.javamain方法調用
packageQQ2014;
publicclassTest{
publicstaticvoidmain(String[]args){
QQ2014qq=newQQ2014();
qq.showLoginFrame();
}
}

❸ 怎樣用JAVA編寫QQ登陸消息框

lei說的對。
我來詳細來說明一下:源
JButton button = new JButton("OK");
button.addActionListener(this);//這個界面實現一個ActionListener

public void actionPerformed(ActionEvent e){
String cmd = e.getActionCommand();
if("OK".equals(cmd)){
validate();
}
}

private JTextField tfName;//這些控制項都假設你自己add到界面里了
private JPasswordField tpPsw;
public void validate(){
String name = tfName.getText();
char[] psw = tpPsw.getPassword();
if("".equals(name)){System.out.println("填寫名字");return;}
if(psw.length<=0){return;}
//下面自己查詢結果,然後比較密碼。可能需要用到一些加密演算法
}

❹ qq 第三方登錄 java sdk怎麼用

導入相關的jar包到你的項目里,剩下就是自己看api文檔,結合自己的項目使用。

❺ java 做QQ

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.ActionEvent;
import java.io.*;
import javax.swing.*;
import java.awt.Button;
import java.awt.Panel;
import java.lang.String;
import javax.swing.JOptionPane;
public class QQ extends Frame implements ActionListener{
Label Lname ,Lpassword; //定義用戶名和密碼的標簽
TextField Tname; //定義用戶名的文本框
JPasswordField Tpassword; //定義密碼的文本框。註:使用JPasswordField的好處就是輸入的密碼是以****顯示給用戶的
Panel panel1=new Panel(); //定義面板
Button Load,login; //定義登陸和注冊的按鈕
boolean b=false;
File file1; //定義記錄用戶注冊的用戶名和密碼的文件
Writer writer;
String []Usersname=new String[1024]; //定義記錄用戶名的數組
String []Userspassword=new String[1024];//定義記錄密碼的數組
public QQ(){
Lname=new Label ("用戶名");Lname.setBackground(Color.red);//設置標簽的背景顏色
Lpassword=new Label ("密碼");Lpassword.setBackground(Color.red);//設置標簽的背景顏色
Tname=new TextField (10);
Tpassword=new JPasswordField (10);
Load=new Button("登陸");Load.setBackground(Color.lightGray);
login=new Button("注冊");login.setBackground(Color.lightGray);
add(panel1,BorderLayout.CENTER);
setLayout(new CardLayout(3,2));
panel1.add(Lname);
panel1.add(Tname);
panel1.add(Lpassword);
panel1.add(Tpassword);
panel1.add(Load);Load.addActionListener(this);
panel1.add(login);login.addActionListener(this);

}
public void actionPerformed(ActionEvent e){
// 用戶登錄事件處理
if (e.getSource() == Load) {
String name1 = Tname.getText();
String password1 = Tpassword.getText();
boolean flag = false;
int index = 0;
for (int i = 0; i < Usersname.length; i++) {
if (name1.equals(Usersname[i])) {
flag = true;
index = i;
break;
}
}
if (flag && password1.equals(Userspassword[index])) {
//處理用戶登錄成功後的反饋信息
JOptionPane.showMessageDialog(null, "恭喜您登陸成功!", "消息", JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "對不起您的用戶名或密碼錯誤!", "錯誤",JOptionPane.ERROR_MESSAGE);
}
}

// 用戶注冊模塊的事件處理
if (e.getSource() == login) {
String NCmp = Tname.getText();
String PCmp = Tpassword.getText();

boolean flag = false;
for (int i = 0; i < Usersname.length; i++) {
if (NCmp.equals(Usersname[i])) {
flag = true;
break;
}
}
if (flag) {
JOptionPane.showMessageDialog(null, "對不起您的用戶名已經注冊!", "錯誤", JOptionPane.ERROR_MESSAGE);
} else {
int index = 0;
JOptionPane.showMessageDialog(null, "注冊成功!", "消息", JOptionPane.INFORMATION_MESSAGE);
for (int i = 0; i < Usersname.length; i++) {
if (Usersname[i] == null) {
Usersname[i] = NCmp;
index = i;
break;
}
}
Userspassword[index] = PCmp;
}
try{
file1=new File("Student.dat");
FileWriter fw=new FileWriter(file1,true);
fw.write("用戶名"+"\t\t"+"密碼"+"\n");
fw.write(NCmp+"\t\t"+PCmp+"\n");
fw.close();
}catch (IOException e1){
e1.printStackTrace();
}
}

}
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame Fstudent=new QQ();
Fstudent.setSize(200,200);
Fstudent.setTitle("QQ模擬系統");

// 關閉窗口
Fstudent.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
Fstudent.setVisible(true);

}

}
自己寫的 呵呵不好意思 主要功能就是登陸 和注冊
注冊有用戶名同名時會提示(報錯)
你運行下 就可以了
不好還可以聯系呵呵
這個東西 還是自己去摸索吧 網上的資料很多 要知道 你如果真的做軟體開發的話 你就要去自學很多東西 而不是 去弄現成的 學會好好 網路吧 而不是提問

❻ 用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 com.demo4;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
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;
import javax.swing.border.EmptyBorder;

public class Demo1 extends JFrame{
public Demo1(){
init();
}
private void init(){
ImageIcon icon=new ImageIcon("Image/8.jpg");
setIconImage(icon.getImage());
setTitle("QQ2011");
setSize(310,270);
setContentPane(createContentPane());
}
private JPanel createContentPane(){
JPanel pane=new JPanel(new BorderLayout());
pane.add(BorderLayout.NORTH,new JLabel(new ImageIcon("Image/5.jpg")));
pane.add(BorderLayout.CENTER,createPane());
pane.add(BorderLayout.SOUTH,createButtonPane());
return pane;
}
private JPanel createPane(){
JPanel pane=new JPanel(new BorderLayout());
pane.setBorder(new EmptyBorder(12,24,12,24));
pane.add(BorderLayout.NORTH,createGridPane());
pane.add(BorderLayout.CENTER,createCheckBoxPane());
return pane;
}
private JPanel createGridPane(){
JPanel pane=new JPanel(new GridLayout(2,1,0,8));
pane.add(createName());
pane.add(createPassword());
return pane;
}
private JPanel createName(){
JPanel pane=new JPanel(new BorderLayout());
pane.add(BorderLayout.WEST,new JLabel("賬號"));
pane.add(BorderLayout.CENTER,new JTextField(10));
pane.add(BorderLayout.EAST,new JButton("清除賬號"));
return pane;
}
private JPanel createPassword(){
JPanel pane=new JPanel(new BorderLayout());
pane.add(BorderLayout.WEST,new JLabel("密碼"));
pane.add(BorderLayout.CENTER,new JPasswordField(10));
pane.add(BorderLayout.EAST,new JButton("忘記密碼"));
return pane;
}
private JPanel createCheckBoxPane(){
JPanel pane=new JPanel(new FlowLayout());
JCheckBox jcb1=new JCheckBox("隱身登陸");
JCheckBox jcb2=new JCheckBox("記住密碼");
pane.add(jcb1);
pane.add(jcb2);
return pane;
}
private JPanel createButtonPane(){
JPanel pane=new JPanel(new FlowLayout());
JButton denglu=new JButton("登陸");
JButton quxiao=new JButton("取消");
JComboBox jcbb=new JComboBox();
String[]jc={"上線","隱身","離線","忙碌"};
jcbb=new JComboBox(jc);
pane.add(denglu);
pane.add(quxiao);
pane.add(jcbb);
return pane;
}
public void ActionListener(){
for(int i=0;i<=i;i++)
System.out.println(i);
}

public void xianshi(){
setVisible(true);
}

}
下面是主函數的代碼 估計包可能還有問題 還有圖片的問題
package com.demo4;

public class Main1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Demo1 a=new Demo1();
a.xianshi();
}

}

閱讀全文

與qqjava介面開發相關的資料

熱點內容
魅藍note3root升級 瀏覽:460
u盤文件夾變成exe病毒查殺 瀏覽:511
中職計算機網路技術教學大綱 瀏覽:219
叮叮如何下載文件 瀏覽:746
大數據趨勢站 瀏覽:768
如何將圖形文件生成雕刻文件 瀏覽:558
mongodb可視化工具下載 瀏覽:377
word2003設置密碼 瀏覽:966
公司文件如何分類 瀏覽:578
如何關閉手機網路信號強度 瀏覽:252
win7怎麼新建word 瀏覽:60
福州孩子哪裡學編程 瀏覽:703
win10關閉server 瀏覽:980
全民飛機升級波塞 瀏覽:779
如何清洗電池的數據 瀏覽:775
電腦怎麼給iphone傳照片 瀏覽:610
word文檔里的圖片位置錯誤 瀏覽:195
win10360wifi打不開 瀏覽:745
2002電腦系統升級 瀏覽:745
被批評的app有哪些 瀏覽:512

友情鏈接