1   package junit.swingui;
2   
3   import java.awt.*;
4   import java.awt.event.*;
5   
6   import javax.swing.*;
7   import junit.runner.*;
8   
9   /***
10   * The AboutDialog.
11   */
12  class AboutDialog extends JDialog {
13  	public AboutDialog(JFrame parent) {
14  		super(parent, true);
15  		 
16  		setResizable(false);
17  		getContentPane().setLayout(new GridBagLayout());
18  		setSize(330, 138);
19  		setTitle("About");
20  		// setLocationRelativeTo is only available in JDK 1.4
21  		try {
22  			setLocationRelativeTo(parent);
23  		} catch (NoSuchMethodError e) {
24  			TestSelector.centerWindow(this);
25  		}
26  
27  		JButton close= new JButton("Close");
28  		close.addActionListener(
29  			new ActionListener() {
30  				public void actionPerformed(ActionEvent e) {
31  					dispose();
32  				}
33  			}
34  		);
35  		getRootPane().setDefaultButton(close);
36  		JLabel label1= new JLabel("JUnit");
37  		label1.setFont(new Font("dialog", Font.PLAIN, 36));
38  		
39  		JLabel label2= new JLabel("JUnit "+Version.id()+" by Kent Beck and Erich Gamma");
40  		label2.setFont(new Font("dialog", Font.PLAIN, 14));
41  		
42  		JLabel logo= createLogo();
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  		getContentPane().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  		getContentPane().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  		getContentPane().add(close, 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  		getContentPane().add(logo, constraintsLogo1);
68  
69  		addWindowListener(
70  			new WindowAdapter() {
71  				public void windowClosing(WindowEvent e) {
72  					dispose();
73  				}
74  			}
75  		);
76  	}
77  	protected JLabel createLogo() {
78  		Icon icon= TestRunner.getIconResource(BaseTestRunner.class, "logo.gif");
79  		return new JLabel(icon);
80  	}
81  }