1 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 ; 32 import java.awt.event.ActionListener ; 33 import java.awt.event.WindowEvent ; 34 35 class AboutDialog extends JDialog { 36 static final String TITLE = "About JRobin"; 37 static final String EMAIL = "saxon@eunet.yu"; 38 static final String 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 () { 90 public void actionPerformed(ActionEvent 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 (this, WindowEvent.WINDOW_CLOSING)); 105 } 106 } 107 | Popular Tags |