1.JAVAç¼åçè天工å
·
2.java 如何模仿QQ聊天框那样可以显示文字与啊?
JAVAç¼åçèå¤©å·¥å ·
//以ä¸å¼å ¥å
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.applet.*;
public class regit extends JApplet implements ActionListener,仿qa仿ItemListener//æ¥å£
{
String s=null;
//对象ç声æ
JLabel labelname,labelpass,labelsxe,labeladdress,labelmail,labelphone;//æ ç¾
JTextField textname,textaddress,textmail,textphone;//ææ¬æ¡
JRadioButton r1,r2;//åéæ纽
ButtonGroup bg;//ç»
JPasswordField textpass;//å¯ç å
JButton buttonregit,buttonreset;//注åæ纽 éåæ纽
JPanel p;//é¢æ¿
String sex;//å®ä¹æ§å«å符串
URL url;//ç»ä¸èµæºå®ä½
BufferedWriter out1,out2;//æµ
BufferedReader in;
//å¸å±æ¹å¼
GridBagLayout gbl;
GridBagConstraints gc;
AppletContext co;//æ¥å£
//åå§å
public void init()
{
//new 对象
labelname=new JLabel("ç¨ æ· å:");
labelpass=new JLabel("ç¨æ·å¯ç :");
labelsxe=new JLabel("æ§å«:");
labeladdress=new JLabel("å°å:");
labelmail=new JLabel("çµåé®ä»¶:");
labelphone=new JLabel("èç³»çµè¯:");
textname=new JTextField(); textname.setForeground(Color.red);
textname.setToolTipText("请å¨è¿è¾å ¥ä½ çç¨æ·å");
textaddress=new JTextField();textaddress.setForeground(Color.red);
textaddress.setToolTipText("请å¨è¿è¾å ¥ä½ çå°å");
textmail=new JTextField(); textmail.setForeground(Color.red);
textmail.setToolTipText("请å¨è¿éè¾å ¥ä½ çE-mailå°å");
textphone=new JTextField(); textphone.setForeground(Color.red);
textphone.setToolTipText("请å¨è¿è¾å ¥ä½ ççµè¯å·ç ");
r1=new JRadioButton("ç·"); r1.setBackground(new Color(,,));//设置é¢è²
r2=new JRadioButton("女"); r2.setBackground(new Color(,,));//设置é¢è²
bg=new ButtonGroup();
bg.add(r1);bg.add(r2);//å å ¥ç»,å®ç°åé
textpass=new JPasswordField();
textpass.setToolTipText("å¨è¿éè¾å ¥å¯ç ");
textpass.setForeground(Color.red);
buttonregit=new JButton("注å"); buttonregit.setBackground(new Color(,,));//设置é¢è²
buttonregit.setToolTipText("ç¹å»æ纽å®æ注å");
buttonreset=new JButton("å¡«å"); buttonreset.setBackground(new Color(,,));//设置é¢è²
buttonreset.setToolTipText("ç¹å»æ纽å·æ°éå");
gbl=new GridBagLayout(); ///////////////////////////////////////
gc=new GridBagConstraints(); //////éç¨GridBagLayoutå¸å±æ¹å¼////////
p=new JPanel();
p.setLayout(gbl);
p.setBackground(new Color(,,));
this.getContentPane().add(p);//å å ¥é¢æ¿
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=2;
gbl.setConstraints(labelname,gc);
p.add(labelname);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=2;
gbl.setConstraints(textname,gc);
p.add(textname);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=4;
gbl.setConstraints(labelpass,gc);
p.add(labelpass);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=4;
gbl.setConstraints(textpass,gc);
p.add(textpass);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=6;
gbl.setConstraints(labelsxe,gc);
p.add(labelsxe);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=6;
gbl.setConstraints(r1,gc);
p.add(r1);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=5;
gc.gridy=6;
gbl.setConstraints(r2,gc);
p.add(r2);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=8;
gbl.setConstraints(labeladdress,gc);
p.add(labeladdress);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=8;
gbl.setConstraints(textaddress,gc);
p.add(textaddress);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=;
gbl.setConstraints(labelmail,gc);
p.add(labelmail);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=;
gbl.setConstraints(textmail,gc);
p.add(textmail);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=;
gbl.setConstraints(labelphone,gc);
p.add(labelphone);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=;
gbl.setConstraints(textphone,gc);
p.add(textphone);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=2;
gc.gridy=;
gbl.setConstraints(buttonregit,gc);
p.add(buttonregit);
gc.anchor=GridBagConstraints.NORTHWEST;
gc.gridx=4;
gc.gridy=;
gbl.setConstraints(buttonreset,gc);
p.add(buttonreset);
/////////////////////////////////////////////
co=this.getAppletContext();
/////////////////////////////////////////////
buttonregit.addActionListener(this);//æ纽äºä»¶ççå¬
buttonreset.addActionListener(this);//æ纽äºä»¶ççå¬
r1.addItemListener(this);//éæ©äºä»¶ççå¬
r2.addItemListener(this);//éæ©äºä»¶ççå¬
textphone.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
//注åæ纽äºä»¶
if(e.getSource()==buttonregit)
{
String s1=textname.getText(); ////////////////////
String s2=new String(textpass.getPassword());////////////////////
String s3=textaddress.getText(); // å®ä¹å符串 //
String s4=textmail.getText(); ////////////////////
String s5=textphone.getText(); ////////////////////
//å¤æ注åèµæ ä¿¡æ¯ æ¯å¦ä¸ºç©º
if(s1.length()==0 || s2.length()==0 ||s3.length()==0 ||s4.length()==0 ||s5.length()==0)
{
int error=JOptionPane.INFORMATION_MESSAGE;
JOptionPane.showMessageDialog(null,"èµæä¸è½ä¸ºç©ºï¼è¯·éæ°æ³¨åï¼","ã温馨æ示ã",error);
return;//å¼¹åºå¯¹è¯æ¡å¹¶è¿å
}
try//åå ¥å°txtæ件
{
in=new BufferedReader(new FileReader("d:\\迷离è§çº¿è天室\\password.txt"));
}
catch(Exception ee){ }
String ss=s1;
try
{
while((s=in.readLine())!=null)
{
if(s.startsWith(ss))
{
JOptionPane.showMessageDialog(null,"ç¨æ·åå·²ç»åå¨ï¼è¯·æ´æ¢ååï¼");
textname.setText("");//设置为空ï¼éæ°è¾å ¥
textpass.setText("");
textaddress.setText("");
textmail.setText("");
textphone.setText("");
return;
}
}
}
catch(Exception ee){ }
///////////////////////////以ä¸ä»£ç å¤ææ¯å¦æåå
{
try
{
out1=new BufferedWriter(new FileWriter("d:\\迷离è§çº¿è天室\\password.txt",true));
out2=new BufferedWriter(new FileWriter("d:\\迷离è§çº¿è天室\\message.txt",true));
}//å建æ件
catch(Exception ee)
{ }
try
{
out1.write(s1+"#"+s2);//å
out1.newLine();
out2.write("ç¨æ·åï¼"+s1);
out2.newLine();
out2.write("å¯ç ï¼"+s2);
out2.newLine();
out2.write("æ§å«ï¼"+sex);
out2.newLine();
out2.write("å°åï¼"+s3);
out2.newLine();
out2.write("çµåé®ä»¶ï¼"+s4);
out2.newLine();
out2.write("çµè¯ï¼"+s5);
out2.newLine();
out1.flush();
out2.flush();//æ¸ çç¼å²
out1.close();
out2.close();
}
catch(Exception ee)
{ }
JOptionPane.showMessageDialog(null,"注åæåï¼");
try
{
String qss="beans画出来嘛。
2、聊聊天轻量化论坛源码可以把输出的天系统源makeblock app源码聊天内容都放在一个StringBuffer里,每打出一句话,系统洋小米源码就把这句话追加在StringBuffer,源码fba源码修改然后把StringBuffer里的仿qa仿运营APP源码内容输出到Textarea中。
3、聊聊天好友列表可以用JList
天系统源天系统源