1 package junit.awtui; 2 3 import java.awt.Button ; 4 import java.awt.Dialog ; 5 import java.awt.Font ; 6 import java.awt.Frame ; 7 import java.awt.GridBagConstraints ; 8 import java.awt.GridBagLayout ; 9 import java.awt.Insets ; 10 import java.awt.Label ; 11 import java.awt.event.ActionEvent ; 12 import java.awt.event.ActionListener ; 13 import java.awt.event.WindowAdapter ; 14 import java.awt.event.WindowEvent ; 15 16 import junit.runner.Version; 17 18 class AboutDialog extends Dialog { 19 public AboutDialog(Frame parent) { 20 super(parent); 21 22 setResizable(false); 23 setLayout(new GridBagLayout ()); 24 setSize(330, 138); 25 setTitle("About"); 26 27 Button button= new Button ("Close"); 28 button.addActionListener( 29 new ActionListener () { 30 public void actionPerformed(ActionEvent e) { 31 dispose(); 32 } 33 } 34 ); 35 36 Label label1= new Label ("JUnit"); 37 label1.setFont(new Font ("dialog", Font.PLAIN, 36)); 38 39 Label label2= new Label ("JUnit "+Version.id()+ " by Kent Beck and Erich Gamma"); 40 label2.setFont(new Font ("dialog", Font.PLAIN, 14)); 41 42 Logo logo= new Logo(); 43 44 GridBagConstraints constraintsLabel1= new GridBagConstraints (); 45 constraintsLabel1.gridx = 3; constraintsLabel1.gridy = 0; 46 constraintsLabel1.gridwidth = 1; constraintsLabel1.gridheight = 1; 47 constraintsLabel1.anchor = GridBagConstraints.CENTER; 48 add(label1, constraintsLabel1); 49 50 GridBagConstraints constraintsLabel2= new GridBagConstraints (); 51 constraintsLabel2.gridx = 2; constraintsLabel2.gridy = 1; 52 constraintsLabel2.gridwidth = 2; constraintsLabel2.gridheight = 1; 53 constraintsLabel2.anchor = GridBagConstraints.CENTER; 54 add(label2, constraintsLabel2); 55 56 GridBagConstraints constraintsButton1= new GridBagConstraints (); 57 constraintsButton1.gridx = 2; constraintsButton1.gridy = 2; 58 constraintsButton1.gridwidth = 2; constraintsButton1.gridheight = 1; 59 constraintsButton1.anchor = GridBagConstraints.CENTER; 60 constraintsButton1.insets= new Insets (8, 0, 8, 0); 61 add(button, constraintsButton1); 62 63 GridBagConstraints constraintsLogo1= new GridBagConstraints (); 64 constraintsLogo1.gridx = 2; constraintsLogo1.gridy = 0; 65 constraintsLogo1.gridwidth = 1; constraintsLogo1.gridheight = 1; 66 constraintsLogo1.anchor = GridBagConstraints.CENTER; 67 add(logo, constraintsLogo1); 68 69 addWindowListener( 70 new WindowAdapter () { 71 public void windowClosing(WindowEvent e) { 72 dispose(); 73 } 74 } 75 ); 76 } 77 } | Popular Tags |