001: package jdepend.swingui;
002:
003: import java.awt.*;
004: import java.awt.event.*;
005: import javax.swing.*;
006:
007: /**
008: * The <code>AboutDialog</code> displays the about information.
009: *
010: * @author <b>Mike Clark</b>
011: * @author Clarkware Consulting, Inc.
012: */
013:
014: class AboutDialog extends JDialog {
015:
016: /**
017: * Constructs an <code>AboutDialog</code> with the specified parent frame.
018: *
019: * @param parent Parent frame.
020: */
021: public AboutDialog(JFrame parent) {
022: super (parent);
023:
024: setTitle("About");
025:
026: setResizable(false);
027:
028: getContentPane().setLayout(new BorderLayout());
029: setSize(300, 200);
030:
031: addWindowListener(new WindowAdapter() {
032:
033: public void windowClosing(WindowEvent e) {
034: dispose();
035: }
036: });
037:
038: JPanel panel = new JPanel();
039: panel.setLayout(new GridBagLayout());
040:
041: JLabel titleLabel = new JLabel("JDepend");
042: titleLabel.setFont(new Font("dialog", Font.BOLD, 18));
043:
044: JLabel nameLabel = new JLabel("Mike Clark");
045: nameLabel.setFont(new Font("dialog", Font.PLAIN, 12));
046:
047: JLabel companyLabel = new JLabel("Clarkware Consulting, Inc.");
048: companyLabel.setFont(new Font("dialog", Font.PLAIN, 12));
049:
050: JLabel httpLabel = new JLabel("www.clarkware.com");
051: httpLabel.setFont(new Font("dialog", Font.PLAIN, 12));
052:
053: JLabel blankLabel = new JLabel(" ");
054:
055: JButton closeButton = createButton("Close");
056:
057: panel.add(titleLabel, createConstraints(1, 1));
058:
059: panel.add(new JLabel(" "), createConstraints(1, 2));
060:
061: panel.add(nameLabel, createConstraints(1, 3));
062:
063: panel.add(companyLabel, createConstraints(1, 4));
064:
065: panel.add(httpLabel, createConstraints(1, 5));
066:
067: panel.add(new JLabel(" "), createConstraints(1, 6));
068: panel.add(new JLabel(" "), createConstraints(1, 7));
069:
070: panel.add(closeButton, createConstraints(1, 9));
071:
072: getContentPane().add("Center", panel);
073:
074: }
075:
076: /**
077: * Creates and returns a button with the specified label.
078: *
079: * @param label Button label.
080: * @return Button.
081: */
082: private JButton createButton(String label) {
083:
084: JButton button = new JButton(label);
085: button.addActionListener(new ActionListener() {
086:
087: public void actionPerformed(ActionEvent e) {
088: dispose();
089: }
090: });
091:
092: return button;
093: }
094:
095: /**
096: * Creates and returns a grid bag constraint with the specified x and y
097: * values.
098: *
099: * @param x X-coordinate.
100: * @param y Y-coordinate.
101: * @return GridBagConstraints
102: */
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: }
|