导航:首页 > 编程语言 > 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接口开发相关的资料

热点内容
jsregexpmatch替换 浏览:848
飞卢小说vip章节破解方法 浏览:497
主角叫陈凡外号屠夫 浏览:305
打印文件隐藏软件 浏览:431
js中时分秒正则表达式 浏览:569
excel文件查看器 浏览:718
电影理发师杀死女友 浏览:419
word2003剪贴板 浏览:208
手机微信文件已过期或已被清理怎么办 浏览:997
免费看会员电影网站 浏览:639
女生去找在北京送快递的男朋友的电影 浏览:67
子非鱼网络技术有限公司 浏览:119
适合二人看的爱情片怦然心动 浏览:830
Linux安装软件还是文件啊 浏览:322
如何在线找网络主播 浏览:493
趣味编程如何下载 浏览:26
测绘大数据处理 浏览:739
appstore禁用银行卡 浏览:369
ios支持文件夹导入的看书软件 浏览:657
微信转账5000元图片 浏览:703

友情链接