java简单聊天室
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class Applet1 extends Applet implements ActionListener,ItemListener
{
TextArea mainText;
JTextField input;
JButton sendButton,disconnectButton,connectButton;
Checkbox secretCheck;
Choice objChoice;
String name="大家";
public void init()
{
mainText=new TextArea("",10,15);
input=new JTextField("",40);
sendButton=new JButton("发送");
sendButton.setForeground(Color.blue);
disconnectButton=new JButton("断开连接");
disconnectButton.setForeground(Color.blue);
connectButton=new JButton("连接主机");
connectButton.setForeground(Color.blue);
secretCheck=new Checkbox("密谈");
objChoice=new Choice();
objChoice.add("大家");
objChoice.add("little girl");
objChoice.add("boy");
this.setBackground(new Color(200,210,50));
add(new ChatPanel());
sendButton.addActionListener(this);
objChoice.addItemListener(this);
}
public void actionPerformed(ActionEvent e)
{
mainText.append("你对"+name+"说:"+input.getText()+"\n");
input.setText("");
}
public void itemStateChanged(ItemEvent e)
{
name=(String)e.getItem();
}
class ChatPa
相关文档:
1、使用java.util.ResourceBundle类的getBundle()方法
示例:
String name = "logging"; // the logging.properties file in src root folder
ResourceBundle rb = ResourceBundle.getBundle(name,Locale.getDefault());
// test the rb
String propertyKey = "xxx";
System.out.println(rb.getString(propert ......
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFrame;
import j ......
1.Java学习网站:
Java中文世界论坛 http://www.chinajavaworld.com/index.jspa
Java世纪网 http://www.java2000.net/
Java 中文站 http://www.java-cn.com/
Java学习室 ......
第一,谈谈final, finally, finalize的区别。
final 用于声明属性,方法和类,分别表示属性不可变,方法不可覆盖,类不可继承。finally是异常处理语句结构的一部分,表示总是执行。finalize是 Object类的一个方法,在垃圾收集器执行的时候会调用被回收对象的此方法,可以覆盖此方法提供垃圾收集时 ......
现在很多人都问 C++和Java 哪个好. 其实技术上各有各的好处与不足,我想大家所说的好不好指得是前途好不好,赚的多不多.
要说赚钱最多的肯定是C++了.因为一门技术是否值钱全看会它的人有多少而不在于这个技术本身的好坏. C++涉及硬件底层的东西比较多,学起来很复杂,会的人少,所以值钱.
&nb ......