KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > ui > about > AboutFrame


1 /* ========================================================================
2  * JCommon : a free general purpose class library for the Java(tm) platform
3  * ========================================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jcommon/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * ---------------
28  * AboutFrame.java
29  * ---------------
30  * (C) Copyright 2001-2004, by Object Refinery Limited.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: AboutFrame.java,v 1.6 2006/03/23 19:47:05 taqua Exp $
36  *
37  * Changes (from 26-Nov-2001)
38  * --------------------------
39  * 26-Nov-2001 : Version 1, based on code from JFreeChart demo application (DG);
40  * 27-Nov-2001 : Added getPreferredSize() method (DG);
41  * 08-Feb-2002 : List of developers is now optional (DG);
42  * 15-Mar-2002 : Modified to use a ResourceBundle for elements that require localisation (DG);
43  * 25-Mar-2002 : Added new constructor (DG);
44  * 26-Jun-2002 : Removed redundant code (DG);
45  * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
46  *
47  */

48
49 package org.jfree.ui.about;
50
51 import java.awt.BorderLayout JavaDoc;
52 import java.awt.Dimension JavaDoc;
53 import java.awt.Image JavaDoc;
54 import java.util.List JavaDoc;
55 import java.util.ResourceBundle JavaDoc;
56 import javax.swing.BorderFactory JavaDoc;
57 import javax.swing.JFrame JavaDoc;
58 import javax.swing.JPanel JavaDoc;
59 import javax.swing.JScrollPane JavaDoc;
60 import javax.swing.JTabbedPane JavaDoc;
61 import javax.swing.JTextArea JavaDoc;
62 import javax.swing.border.Border JavaDoc;
63
64 /**
65  * A frame that displays information about the demonstration application.
66  *
67  * @author David Gilbert
68  */

69 public class AboutFrame extends JFrame JavaDoc {
70
71     /** The preferred size for the frame. */
72     public static final Dimension JavaDoc PREFERRED_SIZE = new Dimension JavaDoc(560, 360);
73
74     /** The default border for the panels in the tabbed pane. */
75     public static final Border JavaDoc STANDARD_BORDER = BorderFactory.createEmptyBorder(5, 5, 5, 5);
76
77     /** Localised resources. */
78     private ResourceBundle JavaDoc resources;
79
80     /** The application name. */
81     private String JavaDoc application;
82
83     /** The application version. */
84     private String JavaDoc version;
85
86     /** The copyright string. */
87     private String JavaDoc copyright;
88
89     /** Other info about the application. */
90     private String JavaDoc info;
91
92     /** The project logo. */
93     private Image JavaDoc logo;
94
95     /** A list of contributors. */
96     private List JavaDoc contributors;
97
98     /** The licence. */
99     private String JavaDoc licence;
100
101     /**
102      * Constructs an about frame.
103      *
104      * @param title the frame title.
105      * @param project information about the project.
106      */

107     public AboutFrame(final String JavaDoc title, final ProjectInfo project) {
108
109         this(title,
110              project.getName(),
111              "Version " + project.getVersion(),
112              project.getInfo(),
113              project.getLogo(),
114              project.getCopyright(),
115              project.getLicenceText(),
116              project.getContributors(),
117              project);
118
119     }
120
121     /**
122      * Constructs an 'About' frame.
123      *
124      * @param title the frame title.
125      * @param application the application name.
126      * @param version the version.
127      * @param info other info.
128      * @param logo an optional logo.
129      * @param copyright the copyright notice.
130      * @param licence the licence.
131      * @param contributors a list of developers/contributors.
132      * @param libraries a list of libraries.
133      */

134     public AboutFrame(final String JavaDoc title,
135                       final String JavaDoc application, final String JavaDoc version, final String JavaDoc info,
136                       final Image JavaDoc logo,
137                       final String JavaDoc copyright, final String JavaDoc licence,
138                       final List JavaDoc contributors,
139                       final ProjectInfo project) {
140
141         super(title);
142
143         this.application = application;
144         this.version = version;
145         this.copyright = copyright;
146         this.info = info;
147         this.logo = logo;
148         this.contributors = contributors;
149         this.licence = licence;
150
151         final String JavaDoc baseName = "org.jfree.ui.about.resources.AboutResources";
152         this.resources = ResourceBundle.getBundle(baseName);
153
154         final JPanel JavaDoc content = new JPanel JavaDoc(new BorderLayout JavaDoc());
155         content.setBorder(STANDARD_BORDER);
156
157         final JTabbedPane JavaDoc tabs = createTabs(project);
158         content.add(tabs);
159         setContentPane(content);
160
161         pack();
162
163     }
164
165     /**
166      * Returns the preferred size for the about frame.
167      *
168      * @return the preferred size.
169      */

170     public Dimension JavaDoc getPreferredSize() {
171         return PREFERRED_SIZE;
172     }
173
174     /**
175      * Creates a tabbed pane containing an about panel and a system properties panel.
176      *
177      * @return a tabbed pane.
178      * @param project
179      */

180     private JTabbedPane JavaDoc createTabs(final ProjectInfo project) {
181
182         final JTabbedPane JavaDoc tabs = new JTabbedPane JavaDoc();
183
184         final JPanel JavaDoc aboutPanel = createAboutPanel(project);
185         aboutPanel.setBorder(AboutFrame.STANDARD_BORDER);
186         final String JavaDoc aboutTab = this.resources.getString("about-frame.tab.about");
187         tabs.add(aboutTab, aboutPanel);
188
189         final JPanel JavaDoc systemPanel = new SystemPropertiesPanel();
190         systemPanel.setBorder(AboutFrame.STANDARD_BORDER);
191         final String JavaDoc systemTab = this.resources.getString("about-frame.tab.system");
192         tabs.add(systemTab, systemPanel);
193
194         return tabs;
195
196     }
197
198     /**
199      * Creates a panel showing information about the application, including the name, version,
200      * copyright notice, URL for further information, and a list of contributors.
201      *
202      * @return a panel.
203      * @param project
204      */

205     private JPanel JavaDoc createAboutPanel(final ProjectInfo project) {
206
207         final JPanel JavaDoc about = new JPanel JavaDoc(new BorderLayout JavaDoc());
208
209         final JPanel JavaDoc details = new AboutPanel(this.application, this.version, this.copyright, this.info,
210                                         this.logo);
211
212         boolean includetabs = false;
213         final JTabbedPane JavaDoc tabs = new JTabbedPane JavaDoc();
214
215         if (this.contributors != null) {
216             final JPanel JavaDoc contributorsPanel = new ContributorsPanel(this.contributors);
217             contributorsPanel.setBorder(AboutFrame.STANDARD_BORDER);
218             final String JavaDoc contributorsTab = this.resources.getString("about-frame.tab.contributors");
219             tabs.add(contributorsTab, contributorsPanel);
220             includetabs = true;
221         }
222
223         if (this.licence != null) {
224             final JPanel JavaDoc licencePanel = createLicencePanel();
225             licencePanel.setBorder(STANDARD_BORDER);
226             final String JavaDoc licenceTab = this.resources.getString("about-frame.tab.licence");
227             tabs.add(licenceTab, licencePanel);
228             includetabs = true;
229         }
230
231         if (project != null) {
232             final JPanel JavaDoc librariesPanel = new LibraryPanel(project);
233             librariesPanel.setBorder(AboutFrame.STANDARD_BORDER);
234             final String JavaDoc librariesTab = this.resources.getString("about-frame.tab.libraries");
235             tabs.add(librariesTab, librariesPanel);
236             includetabs = true;
237         }
238
239         about.add(details, BorderLayout.NORTH);
240         if (includetabs) {
241             about.add(tabs);
242         }
243
244         return about;
245
246     }
247
248     /**
249      * Creates a panel showing the licence.
250      *
251      * @return a panel.
252      */

253     private JPanel JavaDoc createLicencePanel() {
254
255         final JPanel JavaDoc licencePanel = new JPanel JavaDoc(new BorderLayout JavaDoc());
256         final JTextArea JavaDoc area = new JTextArea JavaDoc(this.licence);
257         area.setLineWrap(true);
258         area.setWrapStyleWord(true);
259         area.setCaretPosition(0);
260         area.setEditable(false);
261         licencePanel.add(new JScrollPane JavaDoc(area));
262         return licencePanel;
263
264     }
265
266
267 }
268
Popular Tags