javaqq源代码 手机源代码

用JAVA怎么写QQ

用java是可以写出qq的,只不过用java开发c/s的软件不是java特长的,你要是真的想写,就写着练练手吧,最起码可以巩固java se上的知识。

在乌拉特后等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都做网站、网站设计 网站设计制作按需求定制制作,公司网站建设,企业网站建设,品牌网站制作,营销型网站,外贸营销网站建设,乌拉特后网站建设费用合理。

具体怎么写,给你个大概的思路吧,因为我没办法在这个有限的输入框内把所有的代码写完。

【1】先写出qq的简单界面

【2】给每个按钮添加监听

【3】按钮事件(方法)定义

【4】连接网络(socket)

【5】测试

【5】其他功能添加

【6】测试

怎么用java打开qq

java实现简单QQ登陆界面:

1.生成界面的java代码

package QQ2014;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class QQ2014 {

//创建登陆界面类

public void showLoginFrame(){

//创建船体对象

JFrame loginFrame=new JFrame();

//设置大小,位置,标题

loginFrame.setSize(300,200);

loginFrame.setTitle("QQ2014");

loginFrame.setLocationRelativeTo(null);

//创建流式分布对象

FlowLayout layout=new FlowLayout();

loginFrame.setLayout(layout);

//创建账户名,密码和输入框

JLabel user_name=new JLabel("账号:");

JLabel user_password=new JLabel("密码:");

JTextField field_name=new JTextField(20);

JPasswordField field_password=new JPasswordField(20);

//创建登陆,重置按钮

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

JButton button_login=new JButton("登陆");

//设置窗体可见

loginFrame.setVisible(true);

//创建事件监听对象

ActionListener action_listener1=new ActionListener(){

public void actionPerformed(ActionEvent e){

String name=field_name.getText();

String password=field_password.getText();

if("zhaoxin".equals(name)"123".equals(password))

{

showIndexFrame();

loginFrame.setDefaultCloseOperation(3);

loginFrame.setVisible(false);

}

else{

System.out.println("密码错误,重新输入!");

}

}

};

ActionListener action_listener2=new ActionListener(){

public void actionPerformed(ActionEvent e){

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

}

public void showIndexFrame(){

//创建窗体对象

JFrame indexFrame=new JFrame();

indexFrame.setSize(200,500);

indexFrame.setTitle("QQ好友列表");

indexFrame.setLocationRelativeTo(null);

//设置流式分布对象

FlowLayout layout=new FlowLayout(FlowLayout.CENTER,100,10);

indexFrame.setLayout(layout);

//创建好友按钮

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

{

JButton button_friend=new JButton("friend"+i);

//创建动作事件监听对象

ActionListener action_listener=new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

showChatFrame();

indexFrame.setVisible(false);

indexFrame.setDefaultCloseOperation(3);

}

};

button_friend.addActionListener(action_listener);

indexFrame.add(button_friend);

}

//设置窗体可见

indexFrame.setVisible(true);

}

public void showChatFrame(){

//创建窗体,大小,位置,标题

JFrame chatFrame=new JFrame();

chatFrame.setSize(400,400);

chatFrame.setTitle("正在聊天中...");

chatFrame.setLocationRelativeTo(null);

//创建聊天记录,输入域

JTextArea area_input=new JTextArea(10,30);

JTextArea area_record=new JTextArea(5,30);

//创建流式分布对象

FlowLayout layout=new FlowLayout(FlowLayout.CENTER,0,10);

chatFrame.setLayout(layout);

//创建发送,关闭按扭

JButton button_send=new JButton("发送");

JButton button_close=new JButton("关闭");

//创建动作事件监听对象

ActionListener action_listener1=new ActionListener()

{

public void actionPerformed(ActionEvent e){

area_record.setText(area_record.getText()+"\n"+area_input.getText());

area_input.setText("");

}

};

ActionListener action_listener2=new ActionListener()

{

public void actionPerformed(ActionEvent e){

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.java main方法调用

package QQ2014;

public class Test {

public static void main(String[] args){

QQ2014 qq=new QQ2014();

qq.showLoginFrame();

}

}

手机QQ(JAVA) 修改

铃声就把你自己的铃声改成相应的名字,替换原来的文件就可以了


网站名称:javaqq源代码 手机源代码
文章起源:http://pwwzsj.com/article/hgoids.html