java编写聊天室
import java.awt.*;
import javax.swing.border.*;
import java.net.*;
import javax.swing.*;
import java.awt.event.*;
/**
* 生成设置对话框的类
*/
public class Help extends JDialog {
JPanel titlePanel = new JPanel();
JPanel contentPanel = new JPanel();
JPanel closePanel = new JPanel();
JButton close = new JButton();
JLabel title = new JLabel("聊天室客户端帮助");
JTextArea help = new JTextArea();
Color bg = new Color(255,255,255);
public Help(JFrame frame) {
super(frame, true);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
//设置运行位置,使对话框居中
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation( (int) (screenSize.width - 400) / 2 + 25,
(int) (screenSize.height - 320) / 2);
this.setResizable(false);
}
private void jbInit() throws Exception {
this.setSize(new Dimension(350, 270));
this.setTitle("帮助");
titlePanel.setBackground(bg);;
contentPanel.setBackground(bg);
closePanel.setBackground(bg);
help.setText("1、设置所要连接服务端的IP地址和端口"+
"(默认设置为\n 127.0.0.1:8888)。\n"+
"2、输入你的用户名(默认设置为:匆匆过客)。\n"+
"3、点击“登录”便可以连接到指定的服务器;\n"+
" 点击“注销”可以和服务器端开连接。\n"+
"4、选择需要接受消息的用户,在消息栏中写入消息,\n"+
" 同时选择表情,之后便可发送消息。\n");
help.setEditable(false);
titlePanel.add(new Label(" "));
titlePanel.add(title);
titlePanel.add(new Label(" "));
contentPanel.add(help);
closePanel.add(new Label(" "));
closePanel.add(close);
closePanel.add(new Label(" "));
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(titlePanel, BorderLayout.NORTH);
contentPane.add(contentPanel, BorderLayout.CENTER);
contentPane.add(closePanel, BorderLayout.SOUTH);
close.setText("关闭");
//事件处理
close.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
}
);
}
}
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>