001: /*
002: * This file is part of the QuickServer library
003: * Copyright (C) 2003-2005 QuickServer.org
004: *
005: * Use, modification, copying and distribution of this software is subject to
006: * the terms and conditions of the GNU Lesser General Public License.
007: * You should have received a copy of the GNU LGP License along with this
008: * library; if not, you can download a copy from <http://www.quickserver.org/>.
009: *
010: * For questions, suggestions, bug-reports, enhancement-requests etc.
011: * visit http://www.quickserver.org
012: *
013: */
014:
015: package org.quickserver.net.server.gui;
016:
017: import java.awt.*;
018: import java.awt.event.*;
019: import javax.swing.*;
020: import javax.swing.event.*;
021: import javax.swing.border.*;
022: import java.io.IOException;
023:
024: import org.quickserver.net.server.QuickServer;
025: import org.quickserver.util.TextFile;
026: import org.quickserver.swing.JFrameUtilities;
027:
028: /**
029: * About Panel for QuickServer - GUI Component
030: * @author Akshathkumar Shetty
031: */
032: public class About extends JPanel /*JFrame*/{
033: private ClassLoader classLoader = getClass().getClassLoader();
034: public ImageIcon logo = new ImageIcon(classLoader
035: .getResource("icons/logo.gif"));
036: public ImageIcon logoAbout = new ImageIcon(classLoader
037: .getResource("icons/logo.png"));
038: public ImageIcon ball = new ImageIcon(classLoader
039: .getResource("icons/ball.gif"));
040:
041: private JPanel centerPanel;
042: private JPanel topPanel;
043:
044: private JLabel productName = new JLabel(
045: "<html><font "
046: + "style=\"font-size:35pt;color:#535353\" face=\"Verdana\">"
047: + "<b> QuickServer</b></font>", logoAbout,
048: JLabel.CENTER);
049: private JTextArea readme = new JTextArea();
050: private JScrollPane jsp;
051:
052: String html = "<html><font face=\"verdana\" size=\"2\">";
053:
054: private JLabel versionText = new JLabel(html + "Version", ball,
055: JLabel.LEFT);
056: private JLabel version = new JLabel(html + ": "
057: + QuickServer.getVersion(), JLabel.LEFT);
058:
059: private JLabel licenseText = new JLabel(html + "License", ball,
060: JLabel.LEFT);
061: private JLabel license = new JLabel(html
062: + ": GNU Lesser General Public License", JLabel.LEFT);
063:
064: //private JLabel authorText = new JLabel(html+"Author",ball,JLabel.LEFT);
065: //private JLabel author = new JLabel(html+": Akshathkumar Shetty", JLabel.LEFT);
066:
067: private JLabel copyrightText = new JLabel(html
068: + "Copyright © QuickServer.org", ball, JLabel.LEFT);
069:
070: private JLabel websiteText = new JLabel(html + "Website", ball,
071: JLabel.LEFT);
072: private JLabel website = new JLabel(html
073: + ": http://www.quickserver.org", JLabel.LEFT);
074:
075: private JLabel readmeText = new JLabel(html + "ReadMe", ball,
076: JLabel.LEFT);
077:
078: private GridBagConstraints gbc = new GridBagConstraints();
079:
080: public About() {
081: //Container cp = getContentPane();
082: Container cp = this ;
083:
084: topPanel = new JPanel();
085: topPanel.setLayout(new GridBagLayout());
086: gbc.insets = new Insets(2, 2, 2, 2);
087: gbc.weighty = 0.0;
088: gbc.weightx = 0.0;
089: gbc.gridx = 0;
090: gbc.gridy = 0;
091: gbc.gridheight = 1;
092: gbc.gridwidth = 3;
093: gbc.anchor = GridBagConstraints.CENTER;
094: gbc.fill = GridBagConstraints.NONE;
095: topPanel.add(productName, gbc);
096: /*
097: gbc.gridwidth = 1;
098: gbc.gridx = 2;
099: gbc.weightx = 1.0;
100: gbc.fill = GridBagConstraints.HORIZONTAL;
101: topPanel.add(Box.createHorizontalGlue(), gbc);
102: */
103: gbc.anchor = GridBagConstraints.WEST;
104: gbc.fill = GridBagConstraints.HORIZONTAL;
105:
106: gbc.gridy++; //= 1;
107: gbc.gridx = 0;
108: gbc.weightx = 0.0;
109: topPanel.add(versionText, gbc);
110: gbc.gridx = 1;
111: topPanel.add(version, gbc);
112: gbc.gridx = 2;
113: gbc.weightx = 1.0;
114: gbc.fill = GridBagConstraints.HORIZONTAL;
115: topPanel.add(Box.createHorizontalGlue(), gbc);
116:
117: gbc.gridy++; //= 2;
118: gbc.gridx = 0;
119: gbc.weightx = 0.0;
120: topPanel.add(licenseText, gbc);
121: gbc.gridx = 1;
122: topPanel.add(license, gbc);
123: gbc.gridx = 2;
124: gbc.weightx = 1.0;//1.0
125: gbc.fill = GridBagConstraints.HORIZONTAL;
126: topPanel.add(new JLabel(), gbc);
127:
128: /*
129: gbc.gridy++; // = 3;
130: gbc.gridx = 0;
131: gbc.weightx = 0.0;
132: topPanel.add(authorText, gbc);
133: gbc.gridx = 1;
134: topPanel.add(author, gbc);
135: gbc.gridx = 2;
136: gbc.weightx = 1.0;
137: gbc.fill = GridBagConstraints.HORIZONTAL;
138: topPanel.add(Box.createHorizontalGlue(), gbc);
139: */
140:
141: gbc.gridy++; // = 4;
142: gbc.gridx = 0;
143: gbc.weightx = 0.0;
144: topPanel.add(websiteText, gbc);
145: gbc.gridx = 1;
146: topPanel.add(website, gbc);
147: gbc.gridx = 2;
148: gbc.weightx = 1.0;
149: gbc.fill = GridBagConstraints.HORIZONTAL;
150: topPanel.add(Box.createHorizontalGlue(), gbc);
151:
152: gbc.gridy++; // = 5;
153: gbc.gridx = 0;
154: gbc.weightx = 0.0;
155: gbc.gridwidth = 2;
156: topPanel.add(copyrightText, gbc);
157: gbc.gridwidth = 1;
158: gbc.gridx = 2;
159: gbc.weightx = 1.0;
160: gbc.fill = GridBagConstraints.HORIZONTAL;
161: topPanel.add(Box.createHorizontalGlue(), gbc);
162:
163: gbc.gridy++; // = 6;
164: gbc.gridx = 0;
165: gbc.weightx = 0.0;
166: gbc.gridwidth = 1;
167: topPanel.add(readmeText, gbc);
168: gbc.gridx = 1;
169: topPanel.add(new JLabel(" "), gbc);
170: gbc.gridx = 2;
171: gbc.weightx = 1.0;
172: gbc.fill = GridBagConstraints.HORIZONTAL;
173: topPanel.add(Box.createHorizontalGlue(), gbc);
174:
175: centerPanel = new JPanel();
176: readme.setText("Loading... readme");
177: try {
178: String cont = TextFile.read("/readme.txt",
179: (Object) About.this );
180: readme.setText(cont);
181: } catch (IOException e) {
182: System.err.println("Error reading readme.txt " + e);
183: readme.append("\r\nFailed : " + e.getMessage());
184: }
185: readme.setEditable(false);
186: readme.setLineWrap(true);
187: readme.setWrapStyleWord(true);
188: jsp = new JScrollPane(readme);
189: centerPanel.setLayout(new BorderLayout());
190: centerPanel.add(jsp);
191: centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 9, 0,
192: 9));
193:
194: cp.setLayout(new BorderLayout(0, 10));
195: cp.add(topPanel, BorderLayout.NORTH);
196: cp.add(centerPanel, BorderLayout.CENTER);
197: setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
198: }
199:
200: /**
201: * Displays the about box with in a JFrame.
202: */
203: public static void showAbout() {
204: try {
205: UIManager.setLookAndFeel(UIManager
206: .getSystemLookAndFeelClassName());
207: } catch (Exception e) {
208: }
209:
210: About about = new About();
211: JFrame frame = new JFrame("About QuickServer");
212: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
213: frame.getContentPane().add(about);
214: frame.setSize(600, 500);
215: frame.setIconImage(about.logo.getImage());
216: JFrameUtilities.centerWindow(frame);
217: frame.setVisible(true);
218: }
219:
220: public static void main(String args[]) {
221: java.awt.EventQueue.invokeLater(new Runnable() {
222: public void run() {
223: showAbout();
224: }
225: });
226: }
227: }
|