001: /* ====================================================================
002: * The JRefactory License, Version 1.0
003: *
004: * Copyright (c) 2001 JRefactory. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * 3. The end-user documentation included with the redistribution,
019: * if any, must include the following acknowledgment:
020: * "This product includes software developed by the
021: * JRefactory (http://www.sourceforge.org/projects/jrefactory)."
022: * Alternately, this acknowledgment may appear in the software itself,
023: * if and wherever such third-party acknowledgments normally appear.
024: *
025: * 4. The names "JRefactory" must not be used to endorse or promote
026: * products derived from this software without prior written
027: * permission. For written permission, please contact seguin@acm.org.
028: *
029: * 5. Products derived from this software may not be called "JRefactory",
030: * nor may "JRefactory" appear in their name, without prior written
031: * permission of Chris Seguin.
032: *
033: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
034: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
035: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
036: * DISCLAIMED. IN NO EVENT SHALL THE CHRIS SEGUIN OR
037: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
038: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
039: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
040: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
041: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
042: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
043: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
044: * SUCH DAMAGE.
045: * ====================================================================
046: *
047: * This software consists of voluntary contributions made by many
048: * individuals on behalf of JRefactory. For more information on
049: * JRefactory, please see
050: * <http://www.sourceforge.org/projects/jrefactory>.
051: */
052: package org.acm.seguin.awt;
053:
054: import java.awt.Color;
055: import java.awt.Dimension;
056: import java.awt.FlowLayout;
057: import java.awt.Image;
058: import java.awt.MediaTracker;
059: import java.awt.Point;
060: import java.awt.Toolkit;
061: import java.awt.event.ActionListener;
062: import java.awt.event.ActionEvent;
063: import javax.swing.JWindow;
064: import javax.swing.JFrame;
065: import javax.swing.JLabel;
066: import javax.swing.JButton;
067: import javax.swing.ImageIcon;
068: import java.net.URL;
069: import org.acm.seguin.JRefactoryVersion;
070:
071: /**
072: * About box for the JRefactory software component
073: *
074: *@author Chris Seguin
075: *@created October 18, 2001
076: */
077: public class AboutBox extends JWindow implements ActionListener {
078: /**
079: * Constructor for the AboutBox object
080: */
081: public AboutBox() {
082: super ();
083:
084: getContentPane().setLayout(null);
085:
086: Toolkit kit = getToolkit();
087: setBackground(Color.black);
088: getContentPane().setBackground(Color.black);
089:
090: ImagePanel imagePanel = new ImagePanel("JRefactory.jpg");
091:
092: int width = 0;
093: int maxWidth = 0;
094: int currentHeight = 0;
095:
096: Dimension dim = imagePanel.getPreferredSize();
097: imagePanel.setLocation(25, 5);
098: getContentPane().add(imagePanel);
099:
100: width = 10 + dim.width;
101: maxWidth = Math.max(maxWidth, dim.width);
102: currentHeight = 10 + dim.height;
103:
104: JLabel label1 = new JLabel("Version: "
105: + (new JRefactoryVersion()).toString());
106: label1.setHorizontalAlignment(label1.CENTER);
107: label1.setForeground(Color.red);
108: dim = label1.getPreferredSize();
109: maxWidth = Math.max(maxWidth, dim.width);
110: label1.setSize(dim);
111: label1.setLocation((width - dim.width) / 2, currentHeight);
112: currentHeight += (5 + dim.height);
113: getContentPane().add(label1);
114:
115: JLabel label2 = new JLabel("Author: Chris Seguin");
116: label2.setHorizontalAlignment(label2.CENTER);
117: label2.setForeground(Color.red);
118: dim = label2.getPreferredSize();
119: maxWidth = Math.max(maxWidth, dim.width);
120: label2.setSize(dim);
121: label2.setLocation((width - dim.width) / 2, currentHeight);
122: currentHeight += (5 + dim.height);
123: getContentPane().add(label2);
124:
125: JLabel label3 = new JLabel("Email: seguin@acm.org");
126: label3.setHorizontalAlignment(label3.CENTER);
127: label3.setForeground(Color.red);
128: dim = label3.getPreferredSize();
129: maxWidth = Math.max(maxWidth, dim.width);
130: label3.setSize(dim);
131: label3.setLocation((width - dim.width) / 2, currentHeight);
132: currentHeight += (5 + dim.height);
133: getContentPane().add(label3);
134:
135: JLabel label4 = new JLabel(
136: "Home: http://jrefactory.sourceforge.net");
137: label4.setHorizontalAlignment(label4.CENTER);
138: dim = label4.getPreferredSize();
139: maxWidth = Math.max(maxWidth, dim.width);
140: label4.setSize(dim);
141: label4.setLocation((width - dim.width) / 2, currentHeight);
142: label4.setForeground(Color.red);
143: currentHeight += (5 + dim.height);
144: getContentPane().add(label4);
145:
146: JButton okButton = new JButton("OK");
147: okButton.setForeground(Color.red);
148: okButton.setBackground(Color.black);
149: okButton.addActionListener(this );
150: dim = okButton.getPreferredSize();
151: maxWidth = Math.max(maxWidth, dim.width);
152: okButton.setSize(dim);
153: okButton.setLocation((width - dim.width) / 2, currentHeight);
154: currentHeight += (5 + dim.height);
155: getContentPane().add(okButton);
156:
157: currentHeight += 5;
158: maxWidth += 10;
159: setSize(maxWidth, currentHeight);
160:
161: Point pt = imagePanel.getLocation();
162: dim = imagePanel.getSize();
163: imagePanel.setLocation((maxWidth - dim.width) / 2, 5);
164:
165: pt = label1.getLocation();
166: dim = label1.getSize();
167: label1.setLocation((maxWidth - dim.width) / 2, pt.y);
168:
169: pt = label2.getLocation();
170: dim = label2.getSize();
171: label2.setLocation((maxWidth - dim.width) / 2, pt.y);
172:
173: pt = label3.getLocation();
174: dim = label3.getSize();
175: label3.setLocation((maxWidth - dim.width) / 2, pt.y);
176:
177: pt = label4.getLocation();
178: dim = label4.getSize();
179: label4.setLocation((maxWidth - dim.width) / 2, pt.y);
180:
181: pt = okButton.getLocation();
182: dim = okButton.getSize();
183: okButton.setLocation((maxWidth - dim.width) / 2, pt.y);
184:
185: dim = kit.getScreenSize();
186: setLocation((dim.width - width) / 2,
187: (dim.height - currentHeight) / 2);
188: }
189:
190: /**
191: * Description of the Method
192: *
193: *@param evt Description of the Parameter
194: */
195: public void actionPerformed(ActionEvent evt) {
196: dispose();
197: }
198:
199: /**
200: * The main program for the AboutBox class
201: *
202: *@param args The command line arguments
203: */
204: public static void main(String[] args) {
205: run();
206: }
207:
208: /**
209: * Main processing method for the AboutBox class
210: */
211: public static void run() {
212: (new AboutBox()).show();
213: }
214: }
215: // EOF
|