KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > mrtg > client > AboutDialog


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org);
7  *
8  * (C) Copyright 2003, by Sasa Markovic.
9  *
10  * Developers: Sasa Markovic (saxon@jrobin.org)
11  * Arne Vandamme (cobralord@jrobin.org)
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25 package org.jrobin.mrtg.client;
26
27 import org.jrobin.mrtg.MrtgException;
28
29 import javax.swing.*;
30 import java.awt.*;
31 import java.awt.event.ActionEvent JavaDoc;
32 import java.awt.event.ActionListener JavaDoc;
33 import java.awt.event.WindowEvent JavaDoc;
34
35 class AboutDialog extends JDialog {
36     static final String JavaDoc TITLE = "About JRobin";
37     static final String JavaDoc EMAIL = "saxon@eunet.yu";
38     static final String JavaDoc LOGO = Client.RESOURCE_PATH + "logo.png";
39     private static final int GAP = 3;
40
41     AboutDialog(Frame parent) {
42         super(parent, TITLE);
43         constructUI();
44         pack();
45         Util.centerOnScreen(this);
46         setResizable(false);
47         setModal(true);
48         setVisible(true);
49     }
50
51     private void constructUI() {
52         Box box = Box.createVerticalBox();
53         JLabel logoLabel = new JLabel();
54         try {
55             logoLabel.setIcon(Resources.getImageIcon(LOGO));
56             logoLabel.setAlignmentX(0.5F);
57             logoLabel.setBorder(BorderFactory.createLoweredBevelBorder());
58             box.add(logoLabel);
59             box.add(Box.createVerticalStrut(GAP));
60         }
61         catch(MrtgException e) {
62             e.printStackTrace();
63         }
64         JLabel versionLabel = new JLabel(Client.TITLE);
65         versionLabel.setHorizontalAlignment(JLabel.CENTER);
66         versionLabel.setAlignmentX(0.5F);
67         versionLabel.setMaximumSize(logoLabel.getPreferredSize());
68         box.add(versionLabel);
69         box.add(Box.createVerticalStrut(GAP));
70         JLabel subtitleLabel = new JLabel(Client.SUBTITLE);
71         subtitleLabel.setHorizontalAlignment(JLabel.CENTER);
72         subtitleLabel.setAlignmentX(0.5F);
73         subtitleLabel.setMaximumSize(logoLabel.getPreferredSize());
74         box.add(subtitleLabel);
75         box.add(Box.createVerticalStrut(GAP));
76         JLabel copyrightLabel = new JLabel(Client.COPYRIGHT);
77         copyrightLabel.setHorizontalAlignment(JLabel.CENTER);
78         copyrightLabel.setAlignmentX(0.5F);
79         copyrightLabel.setMaximumSize(logoLabel.getPreferredSize());
80         box.add(copyrightLabel);
81         box.add(Box.createVerticalStrut(GAP));
82         JLabel emailLabel = new JLabel(EMAIL);
83         emailLabel.setHorizontalAlignment(JLabel.CENTER);
84         emailLabel.setAlignmentX(0.5F);
85         emailLabel.setMaximumSize(logoLabel.getPreferredSize());
86         box.add(emailLabel);
87         box.add(Box.createVerticalStrut(2 * GAP));
88         JButton okButton = Util.standardButton("OK");
89         okButton.addActionListener(new ActionListener JavaDoc() {
90             public void actionPerformed(ActionEvent JavaDoc e) { ok(); }
91         });
92         okButton.setAlignmentX(0.5F);
93         box.add(okButton);
94         box.add(Box.createVerticalStrut(GAP));
95         getContentPane().add(box);
96         getRootPane().setDefaultButton(okButton);
97     }
98
99     private void ok() {
100         close();
101     }
102
103     private void close() {
104         dispatchEvent(new WindowEvent JavaDoc(this, WindowEvent.WINDOW_CLOSING));
105     }
106 }
107
Popular Tags