001: /*
002: * Copyright (c) 2007, Sun Microsystems, Inc.
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * * Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in
012: * the documentation and/or other materials provided with the distribution.
013: * * Neither the name of Sun Microsystems, Inc. nor the names of its
014: * contributors may be used to endorse or promote products derived
015: * from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
021: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
022: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
023: * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: */
029:
030: /* Anagram Game Application */
031:
032: package com.toy.anagrams.ui;
033:
034: import java.awt.Dimension;
035: import java.awt.Point;
036: import java.awt.Rectangle;
037: import java.awt.event.ActionListener;
038: import javax.swing.JDialog;
039: import javax.swing.JFrame;
040:
041: /**
042: * About dialog of the Anagram Game application.
043: */
044: public class About extends JDialog {
045:
046: /** Creates new form About */
047: public About(JFrame parent) {
048: super (parent, true);
049: initComponents();
050: pack();
051: Rectangle parentBounds = parent.getBounds();
052: Dimension size = getSize();
053: // Center in the parent
054: int x = Math.max(0, parentBounds.x
055: + (parentBounds.width - size.width) / 2);
056: int y = Math.max(0, parentBounds.y
057: + (parentBounds.height - size.height) / 2);
058: setLocation(new Point(x, y));
059: }
060:
061: /** This method is called from within the constructor to
062: * initialize the form.
063: * WARNING: Do NOT modify this code. The content of this method is
064: * always regenerated by the Form Editor.
065: */
066: private void initComponents() {//GEN-BEGIN:initComponents
067: java.awt.GridBagConstraints gridBagConstraints;
068:
069: mainPanel = new javax.swing.JPanel();
070: copyrightTextArea = new javax.swing.JTextArea();
071: closeButton = new javax.swing.JButton();
072:
073: getContentPane().setLayout(new java.awt.GridBagLayout());
074:
075: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
076: setTitle("About Anagrams");
077: mainPanel.setLayout(new java.awt.GridBagLayout());
078:
079: mainPanel.setBorder(new javax.swing.border.EmptyBorder(
080: new java.awt.Insets(11, 11, 12, 12)));
081: copyrightTextArea.setBackground(javax.swing.UIManager
082: .getDefaults().getColor("Panel.background"));
083: copyrightTextArea.setColumns(25);
084: copyrightTextArea.setEditable(false);
085: copyrightTextArea.setLineWrap(true);
086: copyrightTextArea.setRows(8);
087: copyrightTextArea
088: .setText("Anagrams\n\nCopyright (c) 2003 Irritable Enterprises, Inc.");
089: copyrightTextArea.setWrapStyleWord(true);
090: copyrightTextArea.setBorder(null);
091: copyrightTextArea.setFocusable(false);
092: gridBagConstraints = new java.awt.GridBagConstraints();
093: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
094: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
095: gridBagConstraints.weightx = 1.0;
096: gridBagConstraints.weighty = 1.0;
097: gridBagConstraints.insets = new java.awt.Insets(24, 0, 24, 0);
098: mainPanel.add(copyrightTextArea, gridBagConstraints);
099:
100: closeButton.setMnemonic('C');
101: closeButton.setText("Close");
102: closeButton
103: .addActionListener(new java.awt.event.ActionListener() {
104: public void actionPerformed(
105: java.awt.event.ActionEvent evt) {
106: closeButtonActionPerformed(evt);
107: }
108: });
109:
110: gridBagConstraints = new java.awt.GridBagConstraints();
111: gridBagConstraints.gridx = 0;
112: gridBagConstraints.gridy = 1;
113: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
114: mainPanel.add(closeButton, gridBagConstraints);
115:
116: gridBagConstraints = new java.awt.GridBagConstraints();
117: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
118: gridBagConstraints.weightx = 1.0;
119: gridBagConstraints.weighty = 1.0;
120: getContentPane().add(mainPanel, gridBagConstraints);
121:
122: }//GEN-END:initComponents
123:
124: private void closeButtonActionPerformed(
125: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
126: setVisible(false);
127: dispose();
128: }//GEN-LAST:event_closeButtonActionPerformed
129:
130: // Variables declaration - do not modify//GEN-BEGIN:variables
131: private javax.swing.JButton closeButton;
132: private javax.swing.JTextArea copyrightTextArea;
133: private javax.swing.JPanel mainPanel;
134: // End of variables declaration//GEN-END:variables
135:
136: }
|