1 29 30 31 32 import java.awt.*; 33 import javax.swing.*; 34 35 public class AboutDialog extends JDialog 36 implements Runnable 37 { 38 39 private JLabel aboutLabel1 = new JLabel("SNMP Inquisitor"); 40 private JLabel aboutLabel2 = new JLabel("J. Sevy"); 41 private JLabel aboutLabel3 = new JLabel("November, 2000"); 42 private JLabel aboutLabel4 = new JLabel(""); 43 private JLabel aboutLabel5 = new JLabel(""); 44 45 private String inquisitionString = "\"NO one expects the SNMP Inquisition...\" "; 46 private String mpString = " (- shamelessly adapted from Monty Python's Flying Circus)"; 47 48 Thread displayThread; 49 50 51 public AboutDialog(JFrame parent) 52 { 53 super(parent, "About SNMP Inquisitor", true ); 54 55 this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 56 57 setUpDisplay(); 58 59 this.setLocation(Math.round((parent.getSize().width - this.getSize().width)/2), Math.round((parent.getSize().height - this.getSize().height)/2)); 60 61 displayThread = new Thread (this); 63 displayThread.start(); 64 65 this.show(); 66 67 } 68 69 70 71 72 public void hide() 73 { 74 super.hide(); 75 76 displayThread.interrupt(); 78 } 79 80 81 82 83 private void setUpDisplay() 84 { 85 86 GridBagLayout theLayout = new GridBagLayout(); 88 GridBagConstraints c = new GridBagConstraints(); 89 90 c.gridwidth = 1; 91 c.gridheight = 1; 92 c.fill = GridBagConstraints.NONE; 93 c.ipadx = 0; 94 c.ipady = 0; 95 c.insets = new Insets(2,2,2,2); 96 c.anchor = GridBagConstraints.CENTER; 97 c.weightx = 0; 98 c.weighty = 0; 99 100 JPanel aboutPanel = new JPanel(); 101 aboutPanel.setLayout(theLayout); 102 103 c.gridx = 1; 104 c.gridy = 1; 105 theLayout.setConstraints(aboutLabel1, c); 106 aboutPanel.add(aboutLabel1); 107 108 c.gridx = 1; 109 c.gridy = 2; 110 theLayout.setConstraints(aboutLabel2, c); 111 aboutPanel.add(aboutLabel2); 112 113 c.gridx = 1; 114 c.gridy = 3; 115 theLayout.setConstraints(aboutLabel3, c); 116 aboutPanel.add(aboutLabel3); 117 118 c.gridx = 1; 119 c.gridy = 4; 120 theLayout.setConstraints(aboutLabel4, c); 121 aboutPanel.add(aboutLabel4); 122 123 c.gridx = 1; 124 c.gridy = 5; 125 theLayout.setConstraints(aboutLabel5, c); 126 aboutPanel.add(aboutLabel5); 127 128 129 this.getContentPane().add(aboutPanel); 130 this.pack(); 131 132 this.setSize(300, 150); 133 134 } 135 136 137 138 public void run() 139 { 140 141 142 try 143 { 144 145 146 148 String version = System.getProperty("java.version"); 149 150 153 if (version.compareTo("1.3") >= 0) 154 { 155 AudioFilePlayer audioPlayer = new AudioFilePlayer("SNMPInquisitor.jar", "inquisition.wav"); 156 audioPlayer.playFromJarFile(); 157 } 158 159 int numChars = inquisitionString.length(); 161 162 for (int i = 0; i < numChars; i++) 163 { 164 aboutLabel4.setText(inquisitionString.substring(0,i)); 165 Thread.sleep(60); 166 } 167 168 aboutLabel5.setText(mpString); 169 170 171 } 172 catch(Exception e) 173 { 174 } 177 178 179 } 181 182 183 184 } | Popular Tags |