📄 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 谈话显示区 = new TextArea();
TextArea 私聊显示区 = new TextArea();
TextField 送出信息 = new TextField();
Button 确定 = new Button();
Button 刷新谈话区 = new Button();
Button 刷新私聊区 = 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("用户聊天区");
确定.setLabel("送出信息到:");
确定.addActionListener(new ChatArea_确定_actionAdapter(this));
刷新谈话区.setLabel("刷新谈话区");
刷新谈话区.addActionListener(new ChatArea_刷新谈话区_actionAdapter(this));
刷新私聊区.setLabel("刷新私聊区");
刷新私聊区.addActionListener(new ChatArea_刷新私聊区_actionAdapter(this));
privateChatList.addItemListener(new ChatArea_privateChatList_itemAdapter(this));
contentPane.add(谈话显示区, new XYConstraints(16, 18, 262, 144));
contentPane.add(私聊显示区, new XYConstraints(17, 183, 262, 140));
contentPane.add(送出信息, new XYConstraints(16, 337, 263, 45));
contentPane.add(确定, new XYConstraints(16, 402, 167, 29));
contentPane.add(刷新谈话区, new XYConstraints(16, 438, 168, 28));
contentPane.add(刷新私聊区, 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 刷新谈话区_actionPerformed(ActionEvent e) {
}
public void 刷新私聊区_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_刷新私聊区_actionAdapter
implements ActionListener {
private ChatArea adaptee;
ChatArea_刷新私聊区_actionAdapter(ChatArea adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.刷新私聊区_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);
}
}
class ChatArea_确定_actionAdapter
implements ActionListener {
private ChatArea adaptee;
ChatArea_确定_actionAdapter(ChatArea adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.确定_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -