KickJava   Java API By Example, From Geeks To Geeks.

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


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 HelpDialog extends JDialog {
36     static final String JavaDoc TITLE = "Help";
37     static final String JavaDoc HTML = Client.RESOURCE_PATH + "help.html";
38     static final Dimension SIZE = new Dimension(600, 300);
39
40     HelpDialog(Frame parent) {
41         super(parent, TITLE);
42         constructUI();
43         pack();
44         Util.centerOnScreen(this);
45         setVisible(true);
46     }
47
48     private void constructUI() {
49         Box box = Box.createVerticalBox();
50         JTextPane textPane = new JTextPane();
51         textPane.setContentType("text/html");
52         textPane.setEditable(false);
53         try {
54             textPane.setText(Resources.getString(HTML));
55             textPane.setCaretPosition(0);
56         }
57         catch(MrtgException e) {
58             e.printStackTrace();
59         }
60         JScrollPane scrollPane = new JScrollPane(textPane);
61         scrollPane.setPreferredSize(SIZE);
62         scrollPane.setAlignmentX(0.5F);
63         box.add(scrollPane);
64         box.add(Box.createVerticalStrut(2));
65         JButton okButton = Util.standardButton("Close");
66         okButton.addActionListener(new ActionListener JavaDoc() {
67             public void actionPerformed(ActionEvent JavaDoc e) { ok(); }
68         });
69         okButton.setAlignmentX(0.5F);
70         box.add(okButton);
71         box.add(Box.createVerticalStrut(2));
72         getContentPane().add(box);
73         getRootPane().setDefaultButton(okButton);
74     }
75
76     private void ok() {
77         close();
78     }
79
80     private void close() {
81         dispatchEvent(new WindowEvent JavaDoc(this, WindowEvent.WINDOW_CLOSING));
82     }
83 }
84
Popular Tags