📄 serverpanel.java
字号:
import javax.swing.*;
import java.awt.*;
//import java.awt.event.*;
public class ServerPanel extends JFrame
{
JPanel PServer;
JPanel PChater;
JPanel PUnChater;
JPanel PInfo;
JPanel PJTB;
JToolBar JTB;
JButton button1,button2,button3,button4,button5,button6;
JList LChater;
JTextArea TInfo;
JList LUnChater;
JLabel LbChater,LbUnChater,LInfo;
JScrollPane sp1,sp2,sp3;
Icon icon;
public ServerPanel()
{
PServer=new JPanel();
this.setResizable(false);
PChater=new JPanel();
PUnChater=new JPanel();
PInfo=new JPanel();
PJTB=new JPanel();
this.getContentPane().add(PServer);
PServer.setLayout(new BorderLayout());
PInfo.setLayout(new BorderLayout());
PChater.setLayout(new BorderLayout());
PUnChater.setLayout(new BorderLayout());
PJTB.setLayout(new BorderLayout());
JTB=new JToolBar();
JTB.setEnabled(false);
//JTB.setBackground(Color.white);
//icon=new ImageIcon("../pic/start.gif");
button1=new JButton(new ImageIcon("./Pic/start.gif"));button1.setToolTipText("打开服务器");//button1.setBackground(Color.white);
button2=new JButton(new ImageIcon("./Pic/stop.gif"));button2.setToolTipText("关闭服务器");//button2.setBackground(Color.white);
button3=new JButton(new ImageIcon("./Pic/shutdown.gif"));button3.setToolTipText("退出");//button3.setBackground(Color.white);
button4=new JButton(new ImageIcon("./Pic/about.gif"));button4.setToolTipText("关于");//button4.setBackground(Color.white);
//button5=new JButton();button5.setToolTipText("关闭服务器");
JTB.add(button1);JTB.add(button2);JTB.add(button3);JTB.add(button4);//JTB.add(button5);JTB.add(button6);
PJTB.add(JTB);
LChater=new JList();
TInfo=new JTextArea();
TInfo.setEditable(false);
LUnChater=new JList();
LbChater=new JLabel("|在线人数|");
LbUnChater=new JLabel("|被屏蔽的用户|");
LInfo=new JLabel("|服务器信息|");
sp1=new JScrollPane(LChater);
sp2=new JScrollPane(TInfo);
sp3=new JScrollPane(LUnChater);
LChater.setFixedCellWidth(100);
LUnChater.setFixedCellWidth(100);
PChater.add("North",LbChater);
PChater.add(sp1);
PUnChater.add("North",LbUnChater);
PUnChater.add(sp3);
PInfo.add("North",LInfo);
PInfo.add(sp2);
PServer.add("North",PJTB);
PServer.add("West",PChater);
PServer.add("Center",PInfo);
//PServer.add("East",PUnChater);
Toolkit tk=Toolkit.getDefaultToolkit();
Dimension d=tk.getScreenSize();
int screenwidth=d.width;
int screenheight=d.height;
this.setLocation(screenwidth/4,screenheight/4);
this.setTitle("聊天室服务器");
this.setSize(400,400);
this.setVisible(true);
this.setDefaultCloseOperation(3);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -