📄 nodepropertyframe.java.svn-base
字号:
package collector.gui.view;
import java.awt.event.*;
import javax.swing.*;
import collector.common.*;
import collector.gui.method.*;
import pbs.service.vo.*;
public class NodeProPertyFrame
extends javax.swing.JFrame {
public NodeProPertyFrame(long computer_id) {
jbInit();
this.setComputerId(computer_id);
setNodeProperty();
}
private void jbInit() { //GEN-BEGIN:jbInit
Panel = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
ComputerName = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
ComputerStatus = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
ComputerIp = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
ComputerPri = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
MaxThread = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
UsedThread = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
ComputerCounter = new javax.swing.JLabel();
setTitle("\u8282\u70b9\u5c5e\u6027");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
Panel.setLayout(new java.awt.GridLayout(7, 2));
Panel.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.
EtchedBorder(), "\u524d\u7f6e\u673a\u8282\u70b9\u5c5e\u6027",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION,
new java.awt.Font("Dialog", 0, 12)));
jLabel1.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("\u673a\u5668\u540d\uff1a");
jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel1);
ComputerName.setFont(new java.awt.Font("Dialog", 1, 14));
ComputerName.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
ComputerName.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(ComputerName);
jLabel7.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel7.setText("\u673a\u5668\u72b6\u6001\uff1a");
jLabel7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel7);
ComputerStatus.setFont(new java.awt.Font("Dialog", 1, 14));
ComputerStatus.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
ComputerStatus.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
Panel.add(ComputerStatus);
jLabel5.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel5.setText("IP\u5730\u5740\uff1a");
jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel5);
ComputerIp.setFont(new java.awt.Font("Dialog", 1, 14));
ComputerIp.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
ComputerIp.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
Panel.add(ComputerIp);
jLabel9.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel9.setText("\u4f18\u5148\u7ea7\uff1a");
jLabel9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel9);
ComputerPri.setFont(new java.awt.Font("Dialog", 1, 14));
ComputerPri.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
ComputerPri.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
Panel.add(ComputerPri);
jLabel11.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel11.setText("\u672c\u673a\u6700\u5927\u7ebf\u7a0b\u6570\uff1a");
jLabel11.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel11);
MaxThread.setFont(new java.awt.Font("Dialog", 1, 14));
MaxThread.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
MaxThread.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
Panel.add(MaxThread);
jLabel13.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel13.setText("\u5df2\u7528\u7ebf\u7a0b\u6570\uff1a");
jLabel13.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel13);
UsedThread.setFont(new java.awt.Font("Dialog", 1, 14));
UsedThread.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
UsedThread.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
Panel.add(UsedThread);
jLabel3.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("\u901a\u8baf\u8ba1\u6570\uff1a");
jLabel3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
Panel.add(jLabel3);
ComputerCounter.setFont(new java.awt.Font("Dialog", 1, 14));
ComputerCounter.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
ComputerCounter.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
Panel.add(ComputerCounter);
getContentPane().add(Panel, java.awt.BorderLayout.CENTER);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().
getScreenSize();
setSize(new java.awt.Dimension(306, 338));
setLocation( (screenSize.width - 306) / 2, (screenSize.height - 338) / 2);
} //GEN-END:jbInit
private void exitForm(java.awt.event.WindowEvent evt) { //GEN-FIRST:event_exitForm
//System.exit(0);
FrontGuiDefine.m_NodeProPertyFrame = null;
this.hide();
} //GEN-LAST:event_exitForm
public static void main(String args[]) {
new NodeProPertyFrame( -1).show();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel ComputerCounter;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel ComputerPri;
private javax.swing.JPanel Panel;
private javax.swing.JLabel MaxThread;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel UsedThread;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel ComputerIp;
private javax.swing.JLabel ComputerStatus;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel ComputerName;
private javax.swing.JLabel jLabel5;
// End of variables declaration//GEN-END:variables
long computer_id = -1;
javax.swing.Timer updateTimer = new javax.swing.Timer(5000,
new updateTimerListener());
private void setComputerId(long id) {
this.computer_id = id;
}
private long getComputerId() {
return this.computer_id;
}
private void setNodeProperty() {
computer m_computer = (computer) (CollectorDefine.m_HashComputer.get(new
Long(this.getComputerId())));
if (m_computer != null) {
ComputerName.setText(m_computer.getComputerName());
int comp_status = new Long(m_computer.getComputerStatus()).intValue();
/*
public static final int DEFAULT_MACHINE = 0;
public static final int MASTER_MACHINE = 1;
public static final int SLAVE_MACHINE = 2;
public static final int OUT_OF_RUNNING = 3;
*/
switch (comp_status) {
case CollectorDefine.DEFAULT_MACHINE:
ComputerStatus.setText("未定义");
break;
case CollectorDefine.MASTER_MACHINE:
ComputerStatus.setText("主机");
break;
case CollectorDefine.SLAVE_MACHINE:
//ComputerStatus.setText("备机");
ComputerStatus.setText("从机");
break;
case CollectorDefine.OUT_OF_RUNNING:
ComputerStatus.setText("停用");
default:
ComputerStatus.setText("未定义");
break;
}
ComputerIp.setText(m_computer.getIpAddress());
int computer_pri = m_computer.getPri();
ComputerPri.setText(new Integer(computer_pri).toString());
MaxThread.setText(new Integer(m_computer.getMaxThread()).toString());
UsedThread.setText(new Integer(m_computer.getUsedThread()).toString());
ComputerCounter.setText(new Integer(m_computer.getCounter()).toString());
}
else {
this.setEmptyProperty();
}
}
private void setEmptyProperty() {
ComputerName.setText("");
ComputerStatus.setText("");
ComputerIp.setText("");
ComputerPri.setText("");
MaxThread.setText("");
UsedThread.setText("");
ComputerCounter.setText("");
}
class updateTimerListener
implements java.awt.event.ActionListener {
public void actionPerformed(ActionEvent e) {
try {
setNodeProperty();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -