欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

web服务器监控(一) 博客分类: java综合 SwingJava监控 

程序员文章站 2024-03-17 12:25:04
...

程序截图


web服务器监控(一)
            
    
    博客分类: java综合 SwingJava监控 

原理

定时任务,通过与监控URL建立连接来判断web服务器状态,如果异常,发送邮件通知,如果是139邮箱,同时可接收到手机短信.最终发布时使用fatjar打包,通过one-jar可以将lib打包到一个jar文件中.

 

源码

ServerMonitor

 

package com.gary.ui;

/**
 * 主程序
 * @author gary
 */
public class ServerMonitor {
    public static void main(String[] args){
        MainApp frame = new MainApp();
        frame.setVisible(true);
    }
}

 MainApp

 

package com.gary.ui;

import com.gary.util.ConsoleUtil;
import com.gary.util.MailUtil;
import com.gary.util.StringUtil;
import com.gary.util.SwingUtil;
import com.gary.util.TimeUtil;
import com.gary.util.URLUtil;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.util.Timer;
import java.util.TimerTask;
import javax.imageio.ImageIO;

/**
 * 主界面
 * @author gary
 */
public class MainApp extends javax.swing.JFrame {
    
	private static final long serialVersionUID = 1L;

	//在IDE中调试为false,发布jar包设置为true
	private boolean isPublish = false;
	
	public MainApp() {
        initComponents();
        
        if(isPublish){
        	ICO = "/computer.png";
        }else{
        	ICO = "computer.png";
        }
        
        //系统托盘图标
        systemTray = SystemTray.getSystemTray();
        try {
        	if(isPublish){
        		trayIcon = new TrayIcon(ImageIO.read(getClass().getResource(ICO)));
        	}else{
        		trayIcon = new TrayIcon(ImageIO.read(new File(ICO)));
        	}
            systemTray.add(trayIcon);
        } catch (IOException e1) {
            writeToConsole(e1.getMessage());
        } catch (AWTException e2) {
            writeToConsole(e2.getMessage());
        }

        addWindowListener(new WindowAdapter() {
            @Override
            public void windowIconified(WindowEvent e) {
                // 窗口最小化时dispose该窗口
                dispose();
            }
        });

        trayIcon.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                // 单击托盘窗口再现
                if (e.getClickCount() == 1)
                    setExtendedState(Frame.NORMAL);
                setVisible(true);
            }
        });
        
        try {
        	if(isPublish){
        		setIconImage(ImageIO.read(getClass().getResource(ICO)));
        	}else{
        		setIconImage(ImageIO.read(new java.io.File(ICO)));
        	}
        } catch (IOException e) {
            writeToConsole(e.getMessage());
        }

        //获取屏幕尺寸对象
        Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();

        //水平位置
        int w = (screen.width - width) / 2;
        //垂直位置
        int h = (screen.height - height) / 2;

        setLocation(w,h);
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Service Monitor");
        setSize(width, height);
        writeToConsole("初始化成功");
    }
    
    /**
     * 输出到控制台
     */
    private void writeToConsole(String str){
        ConsoleUtil.write(str);
        consoleText.setText(ConsoleUtil.get());
    }

    /**
     * 初始化
     */
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        userNameLabel = new javax.swing.JLabel();
        smtpText = new javax.swing.JTextField();
        smtpLabel = new javax.swing.JLabel();
        userNameText = new javax.swing.JTextField();
        passwordLabel = new javax.swing.JLabel();
        passwordText = new javax.swing.JPasswordField();
        senderLabel = new javax.swing.JLabel();
        receiverLabel = new javax.swing.JLabel();
        senderText = new javax.swing.JTextField();
        mondayText = new javax.swing.JTextField();
        mailSubjectLabel = new javax.swing.JLabel();
        mailContextLabel = new javax.swing.JLabel();
        mailSubjectText = new javax.swing.JTextField();
        mailContextPane1 = new javax.swing.JScrollPane();
        mailContentText = new javax.swing.JTextArea();
        urlText = new javax.swing.JTextField();
        urlLabel = new javax.swing.JLabel();
        controlButton = new javax.swing.JButton();
        intervalText = new javax.swing.JTextField();
        intervalLabel = new javax.swing.JLabel();
        unitLabel = new javax.swing.JLabel();
        consolePane = new javax.swing.JScrollPane();
        consoleText = new javax.swing.JTextArea();
        clearConsoleButton = new javax.swing.JButton();
        mondayLabel = new javax.swing.JLabel();
        tuesdayLabel = new javax.swing.JLabel();
        wednesdayLabel = new javax.swing.JLabel();
        thursdayLabel = new javax.swing.JLabel();
        fridayLabel = new javax.swing.JLabel();
        saturdayLabel = new javax.swing.JLabel();
        sundayLabel = new javax.swing.JLabel();
        tuesdayText = new javax.swing.JTextField();
        wednesdayText = new javax.swing.JTextField();
        thursdayText = new javax.swing.JTextField();
        fridayText = new javax.swing.JTextField();
        saturdayText = new javax.swing.JTextField();
        sundayText = new javax.swing.JTextField();
        menuBar1 = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        sendTestMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        userNameLabel.setFont(new java.awt.Font("宋体", 0, 12));
        userNameLabel.setText("用户名");
        jPanel1.add(userNameLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, -1, -1));

        smtpText.setFont(new java.awt.Font("宋体", 0, 12));
        smtpText.setText("mail.nou.com.cn");
        jPanel1.add(smtpText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 10, 150, -1));

        smtpLabel.setFont(new java.awt.Font("宋体", 0, 12));
        smtpLabel.setText("SMTP服务器");
        jPanel1.add(smtpLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));

        userNameText.setFont(new java.awt.Font("宋体", 0, 12));
        userNameText.setText("");
        jPanel1.add(userNameText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 40, 150, -1));

        passwordLabel.setFont(new java.awt.Font("宋体", 0, 12));
        passwordLabel.setText("密码");
        jPanel1.add(passwordLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 70, -1, -1));

        passwordText.setFont(new java.awt.Font("宋体", 0, 12));
        passwordText.setText("");
        jPanel1.add(passwordText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 70, 150, -1));

        senderLabel.setFont(new java.awt.Font("宋体", 0, 12));
        senderLabel.setText("发件人");
        jPanel1.add(senderLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 100, -1, -1));

        receiverLabel.setFont(new java.awt.Font("宋体", 0, 12));
        receiverLabel.setText("收件人");
        jPanel1.add(receiverLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 130, -1, -1));

        senderText.setFont(new java.awt.Font("宋体", 0, 12));
        senderText.setText("zhangtongbo08@nou.com.cn");
        jPanel1.add(senderText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 100, 150, -1));

        mondayText.setFont(new java.awt.Font("宋体", 0, 12));
        mondayText.setText("15842634428@139.com");
        mondayText.setToolTipText("多个收件人用;间隔");
        jPanel1.add(mondayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 160, 150, -1));

        mailSubjectLabel.setFont(new java.awt.Font("宋体", 0, 12));
        mailSubjectLabel.setText("邮件主题");
        jPanel1.add(mailSubjectLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 440, -1, -1));

        mailContextLabel.setFont(new java.awt.Font("宋体", 0, 12));
        mailContextLabel.setText("邮件内容");
        jPanel1.add(mailContextLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 470, -1, -1));

        mailSubjectText.setFont(new java.awt.Font("宋体", 0, 12));
        mailSubjectText.setText("服务器已关闭");
        jPanel1.add(mailSubjectText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 440, 150, -1));

        mailContentText.setColumns(20);
        mailContentText.setFont(new java.awt.Font("宋体", 0, 12));
        mailContentText.setRows(5);
        mailContentText.setText("目标服务器已关闭");
        mailContextPane1.setViewportView(mailContentText);

        jPanel1.add(mailContextPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 470, 250, 100));

        urlText.setFont(new java.awt.Font("宋体", 0, 12));
        urlText.setText("http://www.baidu.com/");
        jPanel1.add(urlText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 380, 150, -1));

        urlLabel.setFont(new java.awt.Font("宋体", 0, 12));
        urlLabel.setText("监控URL");
        jPanel1.add(urlLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 380, -1, -1));

        controlButton.setFont(new java.awt.Font("宋体", 0, 12));
        controlButton.setText("开始监控");
        controlButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                controlButtonActionPerformed(evt);
            }
        });
        jPanel1.add(controlButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 580, -1, -1));

        intervalText.setFont(new java.awt.Font("宋体", 0, 12));
        intervalText.setText("10");
        jPanel1.add(intervalText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 410, 70, -1));

        intervalLabel.setFont(new java.awt.Font("宋体", 0, 12));
        intervalLabel.setText("监控间隔");
        jPanel1.add(intervalLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 410, -1, -1));

        unitLabel.setFont(new java.awt.Font("宋体", 0, 12));
        unitLabel.setText("分钟");
        jPanel1.add(unitLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 410, -1, -1));

        consoleText.setColumns(20);
        consoleText.setFont(new java.awt.Font("宋体", 0, 12));
        consoleText.setRows(5);
        consolePane.setViewportView(consoleText);

        jPanel1.add(consolePane, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 10, 240, 560));

        clearConsoleButton.setFont(new java.awt.Font("宋体", 0, 12));
        clearConsoleButton.setText("清空日志");
        clearConsoleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearConsoleButtonActionPerformed(evt);
            }
        });
        jPanel1.add(clearConsoleButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 580, -1, -1));

        mondayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        mondayLabel.setText("星期一");
        jPanel1.add(mondayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 160, -1, -1));

        tuesdayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        tuesdayLabel.setText("星期二");
        jPanel1.add(tuesdayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 190, -1, -1));

        wednesdayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        wednesdayLabel.setText("星期三");
        jPanel1.add(wednesdayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 220, -1, -1));

        thursdayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        thursdayLabel.setText("星期四");
        jPanel1.add(thursdayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 250, -1, -1));

        fridayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        fridayLabel.setText("星期五");
        jPanel1.add(fridayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 280, -1, -1));

        saturdayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        saturdayLabel.setText("星期六");
        jPanel1.add(saturdayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 310, -1, -1));

        sundayLabel.setFont(new java.awt.Font("宋体", 0, 12));
        sundayLabel.setText("星期日");
        jPanel1.add(sundayLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 340, -1, -1));

        tuesdayText.setFont(new java.awt.Font("宋体", 0, 12));
        tuesdayText.setText("15842634428@139.com");
        jPanel1.add(tuesdayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 190, 150, -1));

        wednesdayText.setFont(new java.awt.Font("宋体", 0, 12));
        wednesdayText.setText("15842634428@139.com");
        jPanel1.add(wednesdayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 220, 150, -1));

        thursdayText.setFont(new java.awt.Font("宋体", 0, 12));
        thursdayText.setText("15842634428@139.com");
        jPanel1.add(thursdayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 250, 150, -1));

        fridayText.setFont(new java.awt.Font("宋体", 0, 12));
        fridayText.setText("15842634428@139.com");
        jPanel1.add(fridayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 280, 150, -1));

        saturdayText.setFont(new java.awt.Font("宋体", 0, 12));
        saturdayText.setText("15842634428@139.com");
        jPanel1.add(saturdayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 310, 150, -1));

        sundayText.setFont(new java.awt.Font("宋体", 0, 12));
        sundayText.setText("15842634428@139.com");
        jPanel1.add(sundayText, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 340, 150, -1));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 650, 610));

        fileMenu.setText("文件");
        fileMenu.setFont(new java.awt.Font("宋体", 0, 12));

        sendTestMenuItem.setFont(new java.awt.Font("宋体", 0, 12));
        sendTestMenuItem.setText("发送测试邮件");
        sendTestMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendTestMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(sendTestMenuItem);

        exitMenuItem.setFont(new java.awt.Font("宋体", 0, 12));
        exitMenuItem.setText("退出");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar1.add(fileMenu);

        helpMenu.setText("帮助");
        helpMenu.setFont(new java.awt.Font("宋体", 0, 12));

        aboutMenuItem.setFont(new java.awt.Font("宋体", 0, 12));
        aboutMenuItem.setText("关于");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);

        menuBar1.add(helpMenu);

        setJMenuBar(menuBar1);

        pack();
    }

    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                              
        SwingUtil.show(new AboutDialog(this, false));
    }                                             

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
        System.exit(0);
    }                                            

    private void sendTestMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        try {
            new MailUtil(smtpText.getText(), userNameText.getText(), getPassword())
                                .sendSimpleMail(senderText.getText(), getReceiver(), 
                                mailSubjectText.getText(), mailContentText.getText());
            writeToConsole("测试邮件发送成功");
        }catch(Exception e){
            writeToConsole("发送邮件失败," + e.getMessage()); 
        }
    }                                                

    private void controlButtonActionPerformed(java.awt.event.ActionEvent evt) {                                              
        if(verifyParam()){
            start();
        }
    }                                             

    private void clearConsoleButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        ConsoleUtil.clear();
        consoleText.setText(ConsoleUtil.get());
    }                                                  

    
    public String[] getReceiver(){
        int dayOfWeek = TimeUtil.getDayOfWeek();
        switch(dayOfWeek){
            case 1:
                return sundayText.getText().split(";");
            case 2:
                return mondayText.getText().split(";");
            case 3:
                return tuesdayText.getText().split(";");
            case 4:
                return wednesdayText.getText().split(";");
            case 5:
                return thursdayText.getText().split(";");
            case 6:
                return fridayText.getText().split(";");
            case 7:
                return saturdayText.getText().split(";");
        }
        return null;
    }
    
    /**
     * 开始
     */
    public void start(){
        Double intervalDouble = Double.parseDouble(intervalText.getText());
        intervalDouble  = intervalDouble * 60 * 1000;
        long interval = (long)intervalDouble.longValue();
        Timer timer = new Timer();
        //在0秒后执行此任务,每次间隔interval秒
        //如果传递一个Data参数,就可以在某个固定的时间执行这个任务.
        timer.schedule(new MyTask(), 0, interval);
    }
    
    /**
     * 检查参数
     * @return 
     */
    private boolean verifyParam(){
        if(StringUtil.isBlank(smtpText.getText())){
            writeToConsole("SMTP服务器不能为空");
            return false;
        }
        if(StringUtil.isBlank(userNameText.getText())){
            writeToConsole("用户名不能为空");
            return false;
        }
        if(StringUtil.isBlank(getPassword())){
            writeToConsole("密码不能为空");
            return false;
        }
        if(StringUtil.isBlank(senderText.getText())){
            writeToConsole("发件人错误");
            return false;
        }
        if(StringUtil.isBlank(mondayText.getText())){
            writeToConsole("收件不能为空");
            return false;
        }
        if(StringUtil.isBlank(urlText.getText())){
            writeToConsole("URL不能为空");
            return false;
        }
        if(StringUtil.isBlank(intervalText.getText())){
            writeToConsole("监控间隔不能为空");
            return false;
        }else{
            char[] charArray = intervalText.getText().toCharArray();
            for(int i = 0 ; i < charArray.length ; i++){
                if(Character.isDigit(charArray[i]) || charArray[i] == '.'){
                }else{
                    writeToConsole("监控间隔必须为数字");
                    return false;
                }
            }
        }
        if(StringUtil.isBlank(mailSubjectText.getText())){
            writeToConsole("邮件主题不能为空");
            return false;
        }
        if(StringUtil.isBlank(mailContentText.getText())){
            writeToConsole("邮件内容不能为空");
            return false;
        }
        return true;
    }
    
    
    /**
     * 获取密码
     * @return 
     */
    private String getPassword(){
        StringBuilder password = new StringBuilder();
        char[] pass = passwordText.getPassword();
        for(int i = 0 ; i < pass.length ; i++){
            password.append(pass[i]);
        }
        return password.toString();
    }

    /**
     * 监控
     */
    private class MyTask extends TimerTask{
        @Override
        public void run() {
            try {
                new URLUtil().connect(urlText.getText());
                writeToConsole("服务器状态正常");
            } catch (MalformedURLException ex) {
                writeToConsole("URL填写错误");
            } catch (ConnectException e){
                writeToConsole("服务器已关闭");
                try {
                    new MailUtil(smtpText.getText(), userNameText.getText(), getPassword())
                            .sendSimpleMail(senderText.getText(), getReceiver(), 
                                mailSubjectText.getText(), mailContentText.getText());
                } catch (Exception ex) {
                    writeToConsole("发送邮件失败," + ex.getMessage());
                }
            } catch (IOException ex) {
                writeToConsole("连接错误");
            }
        }
    }
    
    private SystemTray systemTray;
    private TrayIcon trayIcon;
    private static final int width = 672;
    private static final int height = 667;
    private static String ICO = null;
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JButton clearConsoleButton;
    private javax.swing.JScrollPane consolePane;
    private javax.swing.JTextArea consoleText;
    private javax.swing.JButton controlButton;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JLabel fridayLabel;
    private javax.swing.JTextField fridayText;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JLabel intervalLabel;
    private javax.swing.JTextField intervalText;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextArea mailContentText;
    private javax.swing.JLabel mailContextLabel;
    private javax.swing.JScrollPane mailContextPane1;
    private javax.swing.JLabel mailSubjectLabel;
    private javax.swing.JTextField mailSubjectText;
    private javax.swing.JMenuBar menuBar1;
    private javax.swing.JLabel mondayLabel;
    private javax.swing.JTextField mondayText;
    private javax.swing.JLabel passwordLabel;
    private javax.swing.JPasswordField passwordText;
    private javax.swing.JLabel receiverLabel;
    private javax.swing.JLabel saturdayLabel;
    private javax.swing.JTextField saturdayText;
    private javax.swing.JMenuItem sendTestMenuItem;
    private javax.swing.JLabel senderLabel;
    private javax.swing.JTextField senderText;
    private javax.swing.JLabel smtpLabel;
    private javax.swing.JTextField smtpText;
    private javax.swing.JLabel sundayLabel;
    private javax.swing.JTextField sundayText;
    private javax.swing.JLabel thursdayLabel;
    private javax.swing.JTextField thursdayText;
    private javax.swing.JLabel tuesdayLabel;
    private javax.swing.JTextField tuesdayText;
    private javax.swing.JLabel unitLabel;
    private javax.swing.JLabel urlLabel;
    private javax.swing.JTextField urlText;
    private javax.swing.JLabel userNameLabel;
    private javax.swing.JTextField userNameText;
    private javax.swing.JLabel wednesdayLabel;
    private javax.swing.JTextField wednesdayText;
}

 AboutDialog

 

package com.gary.ui;

/**
 * 关于
 * @author gary
 */
public class AboutDialog extends javax.swing.JDialog {

	private static final long serialVersionUID = 1L;

	public AboutDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    private void initComponents() {
        closeButton = new javax.swing.JButton();
        titleLabel = new javax.swing.JLabel();
        qqContentLabel = new javax.swing.JLabel();
        qqlabel = new javax.swing.JLabel();
        blogLabel = new javax.swing.JLabel();
        authorContentLabel = new javax.swing.JLabel();
        emailLabel = new javax.swing.JLabel();
        blogContentLabel = new javax.swing.JLabel();
        authorLabel = new javax.swing.JLabel();
        emailContentLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Server Monitor");

        closeButton.setText("close");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        titleLabel.setText("Server Monitor V1.0");

        qqContentLabel.setText("408036296");

        qqlabel.setFont(new java.awt.Font("宋体", 1, 12));
        qqlabel.setText("QQ:");

        blogLabel.setFont(new java.awt.Font("宋体", 1, 12));
        blogLabel.setText("Blog:");

        authorContentLabel.setText("gary");

        emailLabel.setFont(new java.awt.Font("宋体", 1, 12));
        emailLabel.setText("E-mail:");

        blogContentLabel.setText("http://gary0416.iteye.com/");

        authorLabel.setFont(new java.awt.Font("宋体", 1, 12));
        authorLabel.setText("Author:");

        emailContentLabel.setText("408036296@163.com");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(titleLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(authorLabel)
                        .addGap(11, 11, 11)
                        .addComponent(authorContentLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(blogLabel)
                        .addGap(25, 25, 25)
                        .addComponent(blogContentLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(emailLabel)
                        .addGap(11, 11, 11)
                        .addComponent(emailContentLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(qqlabel)
                        .addGap(39, 39, 39)
                        .addComponent(qqContentLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(80, 80, 80)
                        .addComponent(closeButton)))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(titleLabel)
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(authorLabel)
                    .addComponent(authorContentLabel))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(blogLabel)
                    .addComponent(blogContentLabel))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(emailLabel)
                    .addComponent(emailContentLabel))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(qqlabel)
                    .addComponent(qqContentLabel))
                .addGap(25, 25, 25)
                .addComponent(closeButton)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        pack();
    }

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
        this.setVisible(false);
    }

    private javax.swing.JLabel authorContentLabel;
    private javax.swing.JLabel authorLabel;
    private javax.swing.JLabel blogContentLabel;
    private javax.swing.JLabel blogLabel;
    private javax.swing.JButton closeButton;
    private javax.swing.JLabel emailContentLabel;
    private javax.swing.JLabel emailLabel;
    private javax.swing.JLabel qqContentLabel;
    private javax.swing.JLabel qqlabel;
    private javax.swing.JLabel titleLabel;
}
  • web服务器监控(一)
            
    
    博客分类: java综合 SwingJava监控 
  • 大小: 64.7 KB
相关标签: Swing Java 监控