?? chatarea.java~5~
字號:
package com.soft.Team;
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.awt.event.*;
import java.io.*;
import java.util.Hashtable;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ChatArea
extends JFrame implements Readable{
Socket socket=null;
DataInputStream in=null;
DataOutputStream out=null;
Thread threadMessage=null;
String name=null;
Hashtable listTable;
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
TextArea 談話顯示區(qū) = new TextArea();
TextArea 私聊顯示區(qū) = new TextArea();
TextField 送出信息 = new TextField();
Button 確定 = new Button();
Button 刷新談話區(qū) = new Button();
Button 刷新私聊區(qū) = new Button();
List listComponent = new List();
Choice privateChatList = new Choice();
public ChatArea(String name,Hashtable listTable) {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit(name,listTable);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit(String name,Hashtable listTable) throws Exception {
this.listTable=listTable;
this.name=name;
threadMessage=new Thread(this);
contentPane = (JPanel) getContentPane();
contentPane.setLayout(xYLayout1);
setSize(new Dimension(400, 500));
setTitle("用戶聊天區(qū)");
確定.setLabel("送出信息到:");
確定.addActionListener(new ChatArea_確定_actionAdapter(this));
刷新談話區(qū).setLabel("刷新談話區(qū)");
刷新談話區(qū).addActionListener(new ChatArea_刷新談話區(qū)_actionAdapter(this));
刷新私聊區(qū).setLabel("刷新私聊區(qū)");
刷新私聊區(qū).addActionListener(new ChatArea_刷新私聊區(qū)_actionAdapter(this));
privateChatList.addItemListener(new ChatArea_privateChatList_itemAdapter(this));
contentPane.add(談話顯示區(qū), new XYConstraints(16, 18, 262, 144));
contentPane.add(私聊顯示區(qū), new XYConstraints(17, 183, 262, 140));
contentPane.add(送出信息, new XYConstraints(16, 337, 263, 45));
contentPane.add(確定, new XYConstraints(16, 402, 167, 29));
contentPane.add(刷新談話區(qū), new XYConstraints(16, 438, 168, 28));
contentPane.add(刷新私聊區(qū), new XYConstraints(190, 438, 141, 28));
contentPane.add(listComponent, new XYConstraints(293, 21, 76, 361));
contentPane.add(privateChatList, new XYConstraints(191, 403, 142, 26));
privateChatList=new Choice();
privateChatList.add("大家(*)");
privateChatList.select(0);
}
public void setName(String s)
{
name=s;
}
public void setSocketConnection(Socket socket,DataInputStream in,DataOutputStream out)
{
this.socket=socket;
this.in=in;
this.out=out;
try
{
threadMessage.start();
}
catch(Exception e)
{
}
}
public void run(){
}
public void 確定_actionPerformed(ActionEvent e) {
}
public void 刷新談話區(qū)_actionPerformed(ActionEvent e) {
}
public void 刷新私聊區(qū)_actionPerformed(ActionEvent e) {
}
public void privateChatList_itemStateChanged(ItemEvent e) {
}
}
class ChatArea_privateChatList_itemAdapter
implements ItemListener {
private ChatArea adaptee;
ChatArea_privateChatList_itemAdapter(ChatArea adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.privateChatList_itemStateChanged(e);
}
}
class ChatArea_刷新私聊區(qū)_actionAdapter
implements ActionListener {
private ChatArea adaptee;
ChatArea_刷新私聊區(qū)_actionAdapter(ChatArea adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.刷新私聊區(qū)_actionPerformed(e);
}
}
class ChatArea_刷新談話區(qū)_actionAdapter
implements ActionListener {
private ChatArea adaptee;
ChatArea_刷新談話區(qū)_actionAdapter(ChatArea adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.刷新談話區(qū)_actionPerformed(e);
}
}
class ChatArea_確定_actionAdapter
implements ActionListener {
private ChatArea adaptee;
ChatArea_確定_actionAdapter(ChatArea adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.確定_actionPerformed(e);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -