1:
43:
44: package ;
45:
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53:
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61:
62: import ;
63:
64:
69: public class AboutDialog extends JDialog {
70:
71:
72: public static final Dimension PREFERRED_SIZE = new Dimension(560, 360);
73:
74:
75: public static final Border STANDARD_BORDER
76: = BorderFactory.createEmptyBorder(5, 5, 5, 5);
77:
78:
79: private ResourceBundle resources;
80:
81:
82: private String application;
83:
84:
85: private String version;
86:
87:
88: private String copyright;
89:
90:
91: private String info;
92:
93:
94: private Image logo;
95:
96:
97: private List contributors;
98:
99:
100: private String licence;
101:
102:
108: public AboutDialog(final String title, final ProjectInfo project) {
109:
110: init(title,
111: project.getName(),
112: "Version " + project.getVersion(),
113: project.getInfo(),
114: project.getLogo(),
115: project.getCopyright(),
116: project.getLicenceText(),
117: project.getContributors(),
118: project);
119:
120: }
121:
122:
130: public AboutDialog(final Frame owner,
131: final String title,
132: final ProjectInfo project)
133: {
134: super(owner);
135: init(title,
136: project.getName(),
137: "Version " + project.getVersion(),
138: project.getInfo(),
139: project.getLogo(),
140: project.getCopyright(),
141: project.getLicenceText(),
142: project.getContributors(),
143: project);
144: }
145:
146:
154: public AboutDialog(final Dialog owner,
155: final String title,
156: final ProjectInfo project)
157: {
158: super(owner);
159: init(title,
160: project.getName(),
161: "Version " + project.getVersion(),
162: project.getInfo(),
163: project.getLogo(),
164: project.getCopyright(),
165: project.getLicenceText(),
166: project.getContributors(),
167: project);
168: }
169:
170:
183: private void init (final String title,
184: final String application,
185: final String version,
186: final String info,
187: final Image logo,
188: final String copyright,
189: final String licence,
190: final List contributors,
191: final ProjectInfo libraries) {
192:
193: setTitle(title);
194:
195: this.application = application;
196: this.version = version;
197: this.copyright = copyright;
198: this.info = info;
199: this.logo = logo;
200: this.contributors = contributors;
201: this.licence = licence;
202:
203: final String baseName = "org.jfree.ui.about.resources.AboutResources";
204: this.resources = ResourceBundleWrapper.getBundle(baseName);
205:
206: final JPanel content = new JPanel(new BorderLayout());
207: content.setBorder(STANDARD_BORDER);
208:
209: final JTabbedPane tabs = createTabs(libraries);
210: content.add(tabs);
211: setContentPane(content);
212:
213: pack();
214:
215: }
216:
217:
222: public Dimension getPreferredSize() {
223: return PREFERRED_SIZE;
224: }
225:
226:
234: private JTabbedPane createTabs(final ProjectInfo info) {
235:
236: final JTabbedPane tabs = new JTabbedPane();
237:
238: final JPanel aboutPanel = createAboutPanel(info);
239: aboutPanel.setBorder(AboutDialog.STANDARD_BORDER);
240: final String aboutTab = this.resources.getString(
241: "about-frame.tab.about");
242: tabs.add(aboutTab, aboutPanel);
243:
244: final JPanel systemPanel = new SystemPropertiesPanel();
245: systemPanel.setBorder(AboutDialog.STANDARD_BORDER);
246: final String systemTab = this.resources.getString(
247: "about-frame.tab.system");
248: tabs.add(systemTab, systemPanel);
249:
250: return tabs;
251:
252: }
253:
254:
263: private JPanel createAboutPanel(final ProjectInfo info) {
264:
265: final JPanel about = new JPanel(new BorderLayout());
266:
267: final JPanel details = new AboutPanel(this.application, this.version,
268: this.copyright, this.info, this.logo);
269:
270: boolean includetabs = false;
271: final JTabbedPane tabs = new JTabbedPane();
272:
273: if (this.contributors != null) {
274: final JPanel contributorsPanel = new ContributorsPanel(
275: this.contributors);
276: contributorsPanel.setBorder(AboutDialog.STANDARD_BORDER);
277: final String contributorsTab = this.resources.getString(
278: "about-frame.tab.contributors");
279: tabs.add(contributorsTab, contributorsPanel);
280: includetabs = true;
281: }
282:
283: if (this.licence != null) {
284: final JPanel licencePanel = createLicencePanel();
285: licencePanel.setBorder(STANDARD_BORDER);
286: final String licenceTab = this.resources.getString(
287: "about-frame.tab.licence");
288: tabs.add(licenceTab, licencePanel);
289: includetabs = true;
290: }
291:
292: if (info != null) {
293: final JPanel librariesPanel = new LibraryPanel(info);
294: librariesPanel.setBorder(AboutDialog.STANDARD_BORDER);
295: final String librariesTab = this.resources.getString(
296: "about-frame.tab.libraries");
297: tabs.add(librariesTab, librariesPanel);
298: includetabs = true;
299: }
300:
301: about.add(details, BorderLayout.NORTH);
302: if (includetabs) {
303: about.add(tabs);
304: }
305:
306: return about;
307:
308: }
309:
310:
315: private JPanel createLicencePanel() {
316:
317: final JPanel licencePanel = new JPanel(new BorderLayout());
318: final JTextArea area = new JTextArea(this.licence);
319: area.setLineWrap(true);
320: area.setWrapStyleWord(true);
321: area.setCaretPosition(0);
322: area.setEditable(false);
323: licencePanel.add(new JScrollPane(area));
324: return licencePanel;
325:
326: }
327:
328:
329: }