1 2 3 package com.toy.anagrams.ui; 4 5 import java.awt.Dimension ; 6 import java.awt.Point ; 7 import java.awt.Rectangle ; 8 import java.awt.event.ActionListener ; 9 import javax.swing.JDialog ; 10 import javax.swing.JFrame ; 11 12 15 public class About extends JDialog { 16 17 18 public About(JFrame parent) { 19 super(parent,true); 20 initComponents(); 21 pack(); 22 Rectangle parentBounds = parent.getBounds(); 23 Dimension size = getSize(); 24 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 (x, y)); 28 } 29 30 35 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 37 38 mainPanel = new javax.swing.JPanel (); 39 copyrightTextArea = new javax.swing.JTextArea (); 40 closeButton = new javax.swing.JButton (); 41 42 getContentPane().setLayout(new java.awt.GridBagLayout ()); 43 44 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 45 setTitle("About Anagrams"); 46 mainPanel.setLayout(new java.awt.GridBagLayout ()); 47 48 mainPanel.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (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 (); 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 (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 () { 69 public void actionPerformed(java.awt.event.ActionEvent evt) { 70 closeButtonActionPerformed(evt); 71 } 72 }); 73 74 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (); 81 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 82 gridBagConstraints.weightx = 1.0; 83 gridBagConstraints.weighty = 1.0; 84 getContentPane().add(mainPanel, gridBagConstraints); 85 86 } 88 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) { setVisible(false); 90 dispose(); 91 } 93 94 private javax.swing.JButton closeButton; 96 private javax.swing.JTextArea copyrightTextArea; 97 private javax.swing.JPanel mainPanel; 98 100 } 101 | Popular Tags |