KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > toy > anagrams > ui > About


1 /* Anagram Game Application */
2
3 package com.toy.anagrams.ui;
4
5 import java.awt.Dimension JavaDoc;
6 import java.awt.Point JavaDoc;
7 import java.awt.Rectangle JavaDoc;
8 import java.awt.event.ActionListener JavaDoc;
9 import javax.swing.JDialog JavaDoc;
10 import javax.swing.JFrame JavaDoc;
11
12 /**
13  * About dialog of the Anagram Game application.
14  */

15 public class About extends JDialog JavaDoc {
16
17     /** Creates new form About */
18     public About(JFrame JavaDoc parent) {
19         super(parent,true);
20         initComponents();
21         pack();
22         Rectangle JavaDoc parentBounds = parent.getBounds();
23         Dimension JavaDoc size = getSize();
24         // Center in the parent
25
int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
26         int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
27         setLocation(new Point JavaDoc(x, y));
28     }
29
30     /** This method is called from within the constructor to
31      * initialize the form.
32      * WARNING: Do NOT modify this code. The content of this method is
33      * always regenerated by the Form Editor.
34      */

35     private void initComponents() {//GEN-BEGIN:initComponents
36
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
37
38         mainPanel = new javax.swing.JPanel JavaDoc();
39         copyrightTextArea = new javax.swing.JTextArea JavaDoc();
40         closeButton = new javax.swing.JButton JavaDoc();
41
42         getContentPane().setLayout(new java.awt.GridBagLayout JavaDoc());
43
44         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
45         setTitle("About Anagrams");
46         mainPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
47
48         mainPanel.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(11, 11, 12, 12)));
49         copyrightTextArea.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
50         copyrightTextArea.setColumns(25);
51         copyrightTextArea.setEditable(false);
52         copyrightTextArea.setLineWrap(true);
53         copyrightTextArea.setRows(8);
54         copyrightTextArea.setText("Anagrams\n\nCopyright (c) 2003 Irritable Enterprises, Inc.");
55         copyrightTextArea.setWrapStyleWord(true);
56         copyrightTextArea.setBorder(null);
57         copyrightTextArea.setFocusable(false);
58         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
59         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
60         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
61         gridBagConstraints.weightx = 1.0;
62         gridBagConstraints.weighty = 1.0;
63         gridBagConstraints.insets = new java.awt.Insets JavaDoc(24, 0, 24, 0);
64         mainPanel.add(copyrightTextArea, gridBagConstraints);
65
66         closeButton.setMnemonic('C');
67         closeButton.setText("Close");
68         closeButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
69             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
70                 closeButtonActionPerformed(evt);
71             }
72         });
73
74         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
75         gridBagConstraints.gridx = 0;
76         gridBagConstraints.gridy = 1;
77         gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
78         mainPanel.add(closeButton, gridBagConstraints);
79
80         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
82         gridBagConstraints.weightx = 1.0;
83         gridBagConstraints.weighty = 1.0;
84         getContentPane().add(mainPanel, gridBagConstraints);
85
86     }//GEN-END:initComponents
87

88     private void closeButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_closeButtonActionPerformed
89
setVisible(false);
90         dispose();
91     }//GEN-LAST:event_closeButtonActionPerformed
92

93
94     // Variables declaration - do not modify//GEN-BEGIN:variables
95
private javax.swing.JButton JavaDoc closeButton;
96     private javax.swing.JTextArea JavaDoc copyrightTextArea;
97     private javax.swing.JPanel JavaDoc mainPanel;
98     // End of variables declaration//GEN-END:variables
99

100 }
101
Popular Tags