1 package jdepend.swingui; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 7 13 14 class AboutDialog extends JDialog { 15 16 21 public AboutDialog(JFrame parent) { 22 super(parent); 23 24 setTitle("About"); 25 26 setResizable(false); 27 28 getContentPane().setLayout(new BorderLayout()); 29 setSize(300, 200); 30 31 addWindowListener(new WindowAdapter() { 32 33 public void windowClosing(WindowEvent e) { 34 dispose(); 35 } 36 }); 37 38 JPanel panel = new JPanel(); 39 panel.setLayout(new GridBagLayout()); 40 41 JLabel titleLabel = new JLabel("JDepend"); 42 titleLabel.setFont(new Font("dialog", Font.BOLD, 18)); 43 44 JLabel nameLabel = new JLabel("Mike Clark"); 45 nameLabel.setFont(new Font("dialog", Font.PLAIN, 12)); 46 47 JLabel companyLabel = new JLabel("Clarkware Consulting, Inc."); 48 companyLabel.setFont(new Font("dialog", Font.PLAIN, 12)); 49 50 JLabel httpLabel = new JLabel("www.clarkware.com"); 51 httpLabel.setFont(new Font("dialog", Font.PLAIN, 12)); 52 53 JLabel blankLabel = new JLabel(" "); 54 55 JButton closeButton = createButton("Close"); 56 57 panel.add(titleLabel, createConstraints(1, 1)); 58 59 panel.add(new JLabel(" "), createConstraints(1, 2)); 60 61 panel.add(nameLabel, createConstraints(1, 3)); 62 63 panel.add(companyLabel, createConstraints(1, 4)); 64 65 panel.add(httpLabel, createConstraints(1, 5)); 66 67 panel.add(new JLabel(" "), createConstraints(1, 6)); 68 panel.add(new JLabel(" "), createConstraints(1, 7)); 69 70 panel.add(closeButton, createConstraints(1, 9)); 71 72 getContentPane().add("Center", panel); 73 74 } 75 76 82 private JButton createButton(String label) { 83 84 JButton button = new JButton(label); 85 button.addActionListener(new ActionListener() { 86 87 public void actionPerformed(ActionEvent e) { 88 dispose(); 89 } 90 }); 91 92 return button; 93 } 94 95 103 private GridBagConstraints createConstraints(int x, int y) { 104 105 GridBagConstraints constraints = new GridBagConstraints(); 106 constraints.gridx = x; 107 constraints.gridy = y; 108 constraints.gridwidth = 1; 109 constraints.gridheight = 1; 110 constraints.anchor = GridBagConstraints.CENTER; 111 constraints.weightx = 0.0; 112 constraints.weighty = 0.0; 113 114 return constraints; 115 } 116 117 } | Popular Tags |