📄 bottompane.java
字号:
package server.serverpane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import server.login.ServerFrme;
/**
*服务器管理面板的底部面板
* @author 洪景泉
*
*/
public class BottomPane extends JPanel {
//
private static final long serialVersionUID = 1L;
private JSplitPane sppnTotal = null;
private JSplitPane leftPane = null;
// 左边面板盒子
private Box v1int1Box = null;
private Box h2int1Box = null;
private Box v3int1Box = null;
private Box v3int2Box = null;
private JPanel rightPane = null;
// 左边面板组件
private JLabel labImg = null;
private JButton btnOpen = null;
private JButton btnClose = null;
private JButton btnCoerce = null;
// 右上面板组件
private JTextArea taInfo = null;
private JScrollPane spnInfo = null;
private JPanel pnlInfo = null;
// 右下面板组件
private JTextArea taAffiche = null;
private JScrollPane spAffiche = null;
private JPanel pnlAffiche = null;
private JPanel pnlSend = null;
private JButton btnSend = null;
// 服务器是否启动标志
private boolean isOpen = false;
/**
*构造函数
* @param qqServerFrm 传入的主界面对象
*/
public BottomPane(ServerFrme qqServerFrm) {
// 设置左边面板--盒子
v1int1Box = Box.createVerticalBox();
h2int1Box = Box.createHorizontalBox();
v3int1Box = Box.createVerticalBox();
v3int2Box = Box.createVerticalBox();
// 设置左边面板--组件
labImg = new JLabel();
labImg.setIcon(new ImageIcon("./image/total/disablestate.gif"));
btnOpen = new JButton("开启服务器");
btnClose = new JButton("关闭服务器");
btnCoerce = new JButton("强制下线");
// 设置左边面板--装组件到盒子
v3int1Box.add(labImg);
v3int2Box.add(btnOpen);
v3int2Box.add(Box.createVerticalStrut(15));
v3int2Box.add(btnClose);
v3int2Box.add(Box.createVerticalStrut(30));
v3int2Box.add(btnCoerce);
h2int1Box.add(Box.createHorizontalStrut(20));
h2int1Box.add(v3int1Box);
h2int1Box.add(Box.createHorizontalStrut(20));
h2int1Box.add(v3int2Box);
h2int1Box.add(Box.createHorizontalStrut(20));
v1int1Box.add(h2int1Box);
// 设置右边面板--装盒子到面板
rightPane = new JPanel();
rightPane.setLayout(new BorderLayout(0, 0));
rightPane.add(v1int1Box);
rightPane.setBorder(BorderFactory.createTitledBorder(BorderFactory
.createLineBorder(new Color(144, 185, 229)), "服务器管理"));
rightPane.setBackground(new Color(222, 246, 250));
// 设置左上面板
taInfo =new JTextArea();
spnInfo = new JScrollPane(taInfo);
pnlInfo = new JPanel();
pnlInfo.setLayout(new BorderLayout(0, 0));
pnlInfo.add(spnInfo);
pnlInfo.setBorder(BorderFactory.createTitledBorder(BorderFactory
.createLineBorder(new Color(144, 185, 229)), "系统日志信息"));
pnlInfo.setBackground(new Color(222, 246, 250));
// 设置左下面板
pnlSend = new JPanel();
btnSend = new JButton("发送公告");
Box hBoxTemp = Box.createHorizontalBox();
Box vBoxTemp = Box.createVerticalBox();
hBoxTemp.add(Box.createHorizontalStrut(5));
hBoxTemp.add(btnSend);
hBoxTemp.add(Box.createHorizontalStrut(5));
vBoxTemp.add(hBoxTemp);
FlowLayout f = new FlowLayout(FlowLayout.RIGHT);
pnlSend.setLayout(f);
pnlSend.add(vBoxTemp);
taAffiche = new JTextArea();
spAffiche = new JScrollPane(taAffiche);
pnlAffiche = new JPanel();
pnlAffiche.setLayout(new BorderLayout(0, 0));
pnlAffiche.add(spAffiche);
JPanel pnlTemp = new JPanel(new BorderLayout(0, 0));
pnlTemp.add(pnlAffiche);
pnlTemp.add(pnlSend, BorderLayout.SOUTH);
pnlTemp.setBorder(BorderFactory.createTitledBorder(BorderFactory
.createLineBorder(new Color(144, 185, 229)), "发送公告"));
pnlTemp.setBackground(new Color(222, 246, 250));
pnlSend.setBackground(new Color(222, 246, 250));
// 装面板到分割面板
leftPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pnlInfo, pnlTemp);
leftPane.setDividerLocation(100);
leftPane.setOneTouchExpandable(true);
sppnTotal = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPane,rightPane);
sppnTotal.setOneTouchExpandable(true);
sppnTotal.setDividerLocation(460);
// 装分割面板到面板
this.setLayout(new BorderLayout(0, 0));
this.add(sppnTotal);
this.setBtnEnable(false);
//事件
ServerEvent se=new ServerEvent(qqServerFrm);
btnOpen.addActionListener(se) ;
btnOpen.setActionCommand("open");
btnClose.addActionListener(se);
btnClose.setActionCommand("close");
btnCoerce.addActionListener(se);
btnCoerce.setActionCommand("coerce");
btnSend.addActionListener(se);
btnSend.setActionCommand("affiche");
}
//设置按钮是否可用
public void setBtnEnable(Boolean flag){
btnOpen.setEnabled(!flag);
btnSend.setEnabled(flag);
btnClose.setEnabled(flag);
btnCoerce.setEnabled(flag);
}
public JButton getBtnClose() {
return btnClose;
}
public JButton getBtnOffLine() {
return btnCoerce;
}
public JButton getBtnOpen() {
return btnOpen;
}
public JButton getBtnSend() {
return btnSend;
}
public JTextArea getTaAffiche() {
return taAffiche;
}
public JTextArea getTaInfo() {
return taInfo;
}
public JLabel getLabImg() {
return labImg;
}
public boolean isOpen() {
return isOpen;
}
public void setOpen(boolean isOpen) {
this.isOpen = isOpen;
}
public void setLabImg(JLabel labImg) {
this.labImg = labImg;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -