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
相关文档:
摘选自《Java编程思想》
1. 寄存器(register)。这是最快的存储区,因为它位于不同于其他存储区的地方——处理器内部。但是寄存器的数量极其有限,所以寄存器由编译器根据需求进行分配。你不能直接控制,也不能在程序中感觉到寄存器存在的任何迹象。
2.堆栈(stack)。位于通用RAM(random-access memory, ......
1、在oracle的sys-sysdba下登陆
写一个java source程序链接sqlserver2005:
create or replace and compile java source named test as
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class excutesql1
{
public static String entry ......
1.[http://www.javaalmanac.com] – Java开发者年鉴一书的在线版本. 要想快速查到某种Java技巧的用法及示例代码, 这是一个不错的去处.
2.[http://www.onjava.com] – O’Reilly的Java网站. 每周都有新文章.
3.[http://java.sun.com] – 官方的Java开发者网站 – 每周都有新文章发表.
4.[http:/ ......