1 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 ; 23 24 import org.quickserver.net.server.QuickServer; 25 import org.quickserver.util.TextFile; 26 import org.quickserver.swing.JFrameUtilities; 27 28 32 public class About extends JPanel { 33 private ClassLoader 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 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 61 private JLabel copyrightText = new JLabel(html+"Copyright © 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 = 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 93 gbc.anchor = GridBagConstraints.WEST; 94 gbc.fill = GridBagConstraints.HORIZONTAL; 95 96 gbc.gridy++; 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++; 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; gbc.fill = GridBagConstraints.HORIZONTAL; 116 topPanel.add(new JLabel(), gbc); 117 118 130 131 gbc.gridy++; 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++; 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++; 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 cont = TextFile.read("/readme.txt", 170 (Object )About.this); 171 readme.setText(cont); 172 } 173 catch (IOException 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 194 public static void showAbout(){ 195 try { 196 UIManager.setLookAndFeel( 197 UIManager.getSystemLookAndFeelClassName()); 198 } catch(Exception 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 args[]) { 211 java.awt.EventQueue.invokeLater(new Runnable () { 212 public void run() { 213 showAbout(); 214 } 215 }); 216 } 217 } 218 | Popular Tags |