1.java åQQ
2.java 如何模仿QQ聊天框那样可以显示文字与啊?
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 ,仿q仿Lpassword; //å®ä¹ç¨æ·ååå¯ç çæ ç¾
TextField Tname; //å®ä¹ç¨æ·åçææ¬æ¡
JPasswordField Tpassword; //å®ä¹å¯ç çææ¬æ¡ã注ï¼ä½¿ç¨JPasswordFieldç好å¤å°±æ¯è¾å ¥çå¯ç æ¯ä»¥****æ¾ç¤ºç»ç¨æ·ç
Panel panel1=new Panel(); //å®ä¹é¢æ¿
Button Load,login; //å®ä¹ç»éå注åçæé®
boolean b=false;
File file1; //å®ä¹è®°å½ç¨æ·æ³¨åçç¨æ·ååå¯ç çæ件夹
Writer writer;
String []Usersname=new String[]; //å®ä¹è®°å½ç¨æ·åçæ°ç»
String []Userspassword=new String[];//å®ä¹è®°å½å¯ç çæ°ç»
public QQ(){
Lname=new Label ("ç¨æ·å");Lname.setBackground(Color.red);//设置æ ç¾çèæ¯é¢è²
Lpassword=new Label ("å¯ç ");Lpassword.setBackground(Color.red);//设置æ ç¾çèæ¯é¢è²
Tname=new TextField ();
Tpassword=new JPasswordField ();
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(,);
Fstudent.setTitle("QQ仿çç³»ç»");
// å ³éçªå£
Fstudent.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
Fstudent.setVisible(true);
}
}
èªå·±åç åµåµä¸å¥½ææ 主è¦åè½å°±æ¯ç»é å注å
注åæç¨æ·åååæ¶ä¼æ示ï¼æ¥éï¼
ä½ è¿è¡ä¸ å°±å¯ä»¥äº
ä¸å¥½è¿å¯ä»¥èç³»åµåµ
è¿ä¸ªä¸è¥¿ è¿æ¯èªå·±å»æ¸ç´¢å§ ç½ä¸çèµæå¾å¤ è¦ç¥é ä½ å¦æççå软件å¼åçè¯ ä½ å°±è¦å»èªå¦å¾å¤ä¸è¥¿ èä¸æ¯ å»å¼ç°æç å¦ä¼å¥½å¥½ ç¾åº¦å§ èä¸æ¯æé®
java 如何模仿QQ聊天框那样可以显示文字与啊?
1、swing的码ja模潜艇大战游戏源码界面可以直接用netbeans画出来嘛。2、仿q仿源码增量事件可以把输出的码ja模applepay支付源码聊天内容都放在一个StringBuffer里,每打出一句话,仿q仿BD波段源码就把这句话追加在StringBuffer,码ja模阿里euler 源码然后把StringBuffer里的仿q仿内容输出到Textarea中。
3、码ja模好友列表可以用JList
仿q仿仿q仿