KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > net > server > gui > About


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package org.quickserver.net.server.gui;
16
17 import java.awt.*;
18 import java.awt.event.*;
19 import javax.swing.*;
20 import javax.swing.event.*;
21 import javax.swing.border.*;
22 import java.io.IOException JavaDoc;
23
24 import org.quickserver.net.server.QuickServer;
25 import org.quickserver.util.TextFile;
26 import org.quickserver.swing.JFrameUtilities;
27
28 /**
29  * About Panel for QuickServer - GUI Component
30  * @author Akshathkumar Shetty
31  */

32 public class About extends JPanel /*JFrame*/{
33     private ClassLoader JavaDoc classLoader = getClass().getClassLoader();
34     public ImageIcon logo = new ImageIcon(
35         classLoader.getResource("icons/logo.gif"));
36     public ImageIcon logoAbout = new ImageIcon(
37         classLoader.getResource("icons/logo.png"));
38     public ImageIcon ball = new ImageIcon(
39         classLoader.getResource("icons/ball.gif"));
40
41     private JPanel centerPanel;
42     private JPanel topPanel;
43
44     private JLabel productName = new JLabel("<html><font "+
45         "style=\"font-size:35pt;color:#535353\" face=\"Verdana\">"+
46         "<b> QuickServer</b></font>",logoAbout,JLabel.CENTER);
47     private JTextArea readme = new JTextArea();
48     private JScrollPane jsp;
49
50     String JavaDoc html="<html><font face=\"verdana\" size=\"2\">";
51
52     private JLabel versionText = new JLabel(html+"Version",ball,JLabel.LEFT);
53     private JLabel version = new JLabel(html+": "+QuickServer.getVersion(), JLabel.LEFT);
54
55     private JLabel licenseText = new JLabel(html+"License",ball,JLabel.LEFT);
56     private JLabel license = new JLabel(html+": GNU Lesser General Public License", JLabel.LEFT);
57
58     //private JLabel authorText = new JLabel(html+"Author",ball,JLabel.LEFT);
59
//private JLabel author = new JLabel(html+": Akshathkumar Shetty", JLabel.LEFT);
60

61     private JLabel copyrightText = new JLabel(html+"Copyright &copy; QuickServer.org",ball,JLabel.LEFT);
62
63     private JLabel websiteText = new JLabel(html+"Website",ball,JLabel.LEFT);
64     private JLabel website = new JLabel(html+": http://www.quickserver.org", JLabel.LEFT);
65
66     private JLabel readmeText = new JLabel(html+"ReadMe",ball,JLabel.LEFT);
67
68     private GridBagConstraints gbc = new GridBagConstraints();
69
70     public About() {
71         //Container cp = getContentPane();
72
Container cp = this;
73
74         topPanel = new JPanel();
75         topPanel.setLayout(new GridBagLayout());
76         gbc.insets = new Insets( 2, 2, 2, 2 );
77         gbc.weighty = 0.0;
78         gbc.weightx = 0.0;
79         gbc.gridx = 0;
80         gbc.gridy = 0;
81         gbc.gridheight = 1;
82         gbc.gridwidth = 3;
83         gbc.anchor = GridBagConstraints.CENTER;
84         gbc.fill = GridBagConstraints.NONE;
85         topPanel.add(productName, gbc);
86         /*
87         gbc.gridwidth = 1;
88         gbc.gridx = 2;
89         gbc.weightx = 1.0;
90         gbc.fill = GridBagConstraints.HORIZONTAL;
91         topPanel.add(Box.createHorizontalGlue(), gbc);
92         */

93         gbc.anchor = GridBagConstraints.WEST;
94         gbc.fill = GridBagConstraints.HORIZONTAL;
95
96         gbc.gridy++; //= 1;
97
gbc.gridx = 0;
98         gbc.weightx = 0.0;
99         topPanel.add(versionText, gbc);
100         gbc.gridx = 1;
101         topPanel.add(version, gbc);
102         gbc.gridx = 2;
103         gbc.weightx = 1.0;
104         gbc.fill = GridBagConstraints.HORIZONTAL;
105         topPanel.add(Box.createHorizontalGlue(), gbc);
106
107         gbc.gridy++; //= 2;
108
gbc.gridx = 0;
109         gbc.weightx = 0.0;
110         topPanel.add(licenseText, gbc);
111         gbc.gridx = 1;
112         topPanel.add(license, gbc);
113         gbc.gridx = 2;
114         gbc.weightx = 1.0;//1.0
115
gbc.fill = GridBagConstraints.HORIZONTAL;
116         topPanel.add(new JLabel(), gbc);
117         
118         /*
119         gbc.gridy++; // = 3;
120         gbc.gridx = 0;
121         gbc.weightx = 0.0;
122         topPanel.add(authorText, gbc);
123         gbc.gridx = 1;
124         topPanel.add(author, gbc);
125         gbc.gridx = 2;
126         gbc.weightx = 1.0;
127         gbc.fill = GridBagConstraints.HORIZONTAL;
128         topPanel.add(Box.createHorizontalGlue(), gbc);
129         */

130
131         gbc.gridy++; // = 4;
132
gbc.gridx = 0;
133         gbc.weightx = 0.0;
134         topPanel.add(websiteText, gbc);
135         gbc.gridx = 1;
136         topPanel.add(website, gbc);
137         gbc.gridx = 2;
138         gbc.weightx = 1.0;
139         gbc.fill = GridBagConstraints.HORIZONTAL;
140         topPanel.add(Box.createHorizontalGlue(), gbc);
141
142         gbc.gridy++; // = 5;
143
gbc.gridx = 0;
144         gbc.weightx = 0.0;
145         gbc.gridwidth = 2;
146         topPanel.add(copyrightText, gbc);
147         gbc.gridwidth = 1;
148         gbc.gridx = 2;
149         gbc.weightx = 1.0;
150         gbc.fill = GridBagConstraints.HORIZONTAL;
151         topPanel.add(Box.createHorizontalGlue(), gbc);
152         
153         gbc.gridy++; // = 6;
154
gbc.gridx = 0;
155         gbc.weightx = 0.0;
156         gbc.gridwidth = 1;
157         topPanel.add(readmeText, gbc);
158         gbc.gridx = 1;
159         topPanel.add(new JLabel(" "), gbc);
160         gbc.gridx = 2;
161         gbc.weightx = 1.0;
162         gbc.fill = GridBagConstraints.HORIZONTAL;
163         topPanel.add(Box.createHorizontalGlue(), gbc);
164         
165
166         centerPanel = new JPanel();
167         readme.setText("Loading... readme");
168         try {
169             String JavaDoc cont = TextFile.read("/readme.txt",
170                 (Object JavaDoc)About.this);
171             readme.setText(cont);
172         }
173         catch (IOException JavaDoc e){
174             System.err.println("Error reading readme.txt "+e);
175             readme.append("\r\nFailed : "+e.getMessage());
176         }
177         readme.setEditable(false);
178         readme.setLineWrap(true);
179         readme.setWrapStyleWord(true);
180         jsp = new JScrollPane(readme);
181         centerPanel.setLayout(new BorderLayout());
182         centerPanel.add(jsp);
183         centerPanel.setBorder(BorderFactory.createEmptyBorder(0,9,0,9));
184
185         cp.setLayout(new BorderLayout(0,10));
186         cp.add(topPanel,BorderLayout.NORTH);
187         cp.add(centerPanel,BorderLayout.CENTER);
188         setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
189     }
190
191     /**
192      * Displays the about box with in a JFrame.
193      */

194     public static void showAbout(){
195         try {
196           UIManager.setLookAndFeel(
197             UIManager.getSystemLookAndFeelClassName());
198         } catch(Exception JavaDoc e) {}
199
200         About about = new About();
201         JFrame frame = new JFrame("About QuickServer");
202         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
203         frame.getContentPane().add(about);
204         frame.setSize(600, 500);
205         frame.setIconImage(about.logo.getImage());
206         JFrameUtilities.centerWindow(frame);
207         frame.setVisible(true);
208     }
209
210     public static void main(String JavaDoc args[]) {
211         java.awt.EventQueue.invokeLater(new Runnable JavaDoc() {
212             public void run() {
213                 showAbout();
214             }
215         });
216     }
217 }
218
Popular Tags