private void init() { UIUtils.addEscapeListener(this); // 关闭行为 setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setResizable(false); setLayout(null); pack(); setSize(372, 420); // 添加显示组件 addComponent(new JLabel("采集编号:"), new Rectangle(30, 10, 80, 22)); addJTextComponent(new JTextPane(), status.getMonitor(), new Rectangle(100, 10, 220, 22)); addComponent(new JLabel("主机名称:"), new Rectangle(30, 40, 80, 22)); addJTextComponent(new JTextPane(), status.getName(), new Rectangle(100, 40, 220, 22)); addComponent(new JLabel("主机地址:"), new Rectangle(30, 70, 80, 22)); addJTextComponent(new JTextPane(), status.getAddress(), new Rectangle(100, 70, 220, 22)); addComponent(new JLabel("采集类型:"), new Rectangle(30, 100, 80, 22)); addJTextComponent( new JTextPane(), "daily".equals(status.getType()) ? "忙时" : ("report".equals(status.getType()) ? "服务" : "常规"), new Rectangle(100, 100, 220, 22)); addComponent(new JLabel("更新时间:"), new Rectangle(30, 130, 80, 22)); addJTextComponent(new JTextPane(), status.getDate(), new Rectangle(100, 130, 220, 22)); addComponent(new JLabel("工作目录:"), new Rectangle(30, 160, 80, 22)); addJTextComponent(new JTextPane(), status.getCatalog(), new Rectangle(100, 160, 220, 22)); addComponent(new JLabel("版本:"), new Rectangle(30, 190, 80, 22)); addJTextComponent(new JTextPane(), status.getVersion(), new Rectangle(100, 190, 220, 22)); addComponent(new JLabel("启动日期:"), new Rectangle(30, 220, 80, 22)); String start = status.getStart(); // 格式化程序启动日期 SimpleDateFormat sdf = new SimpleDateFormat("MMMdd", Locale.US); try { Date date = sdf.parse(start); sdf.applyPattern("MM-dd"); start = sdf.format(date); } catch (ParseException e) { } addJTextComponent(new JTextPane(), start, new Rectangle(100, 220, 220, 22)); addComponent(new JLabel("当前命令:"), new Rectangle(30, 250, 80, 22)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(100, 250, 220, 82); JTextPane txtCommand = new JTextPane(); txtCommand.setEditable(false); txtCommand.setText(status.getCommand()); scrollPane.setViewportView(txtCommand); scrollPane.setBorder(null); add(scrollPane); JButton btnFtp = new JButton("上传"); btnFtp.setToolTipText("上传文件至监测点"); btnFtp.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { upload(); } }); addComponent(btnFtp, new Rectangle(80, 350, 62, 24)); JButton btnRestart = new JButton("重启"); btnRestart.setToolTipText("重新启动采集程序"); btnRestart.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { restart(); } }); addComponent(btnRestart, new Rectangle(152, 350, 62, 24)); JButton btnStop = new JButton("停止"); btnStop.setToolTipText("停止采集程序"); btnStop.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { stop(); } }); addComponent(btnStop, new Rectangle(224, 350, 62, 24)); UIUtils.setCenter(this); setVisible(true); }