1 42 43 package org.jfree.ui.about; 44 45 import java.awt.BorderLayout ; 46 import java.awt.Dialog ; 47 import java.awt.Dimension ; 48 import java.awt.Frame ; 49 import java.awt.Image ; 50 import java.util.List ; 51 import java.util.ResourceBundle ; 52 import javax.swing.BorderFactory ; 53 import javax.swing.JDialog ; 54 import javax.swing.JPanel ; 55 import javax.swing.JScrollPane ; 56 import javax.swing.JTabbedPane ; 57 import javax.swing.JTextArea ; 58 import javax.swing.border.Border ; 59 60 65 public class AboutDialog extends JDialog { 66 67 68 public static final Dimension PREFERRED_SIZE = new Dimension (560, 360); 69 70 71 public static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(5, 5, 5, 5); 72 73 74 private ResourceBundle resources; 75 76 77 private String application; 78 79 80 private String version; 81 82 83 private String copyright; 84 85 86 private String info; 87 88 89 private Image logo; 90 91 92 private List contributors; 93 94 95 private String licence; 96 97 103 public AboutDialog(final String title, final ProjectInfo project) { 104 105 init(title, 106 project.getName(), 107 "Version " + project.getVersion(), 108 project.getInfo(), 109 project.getLogo(), 110 project.getCopyright(), 111 project.getLicenceText(), 112 project.getContributors(), 113 project); 114 115 } 116 117 123 public AboutDialog(final Frame owner, 124 final String title, 125 final ProjectInfo project) 126 { 127 super(owner); 128 init(title, 129 project.getName(), 130 "Version " + project.getVersion(), 131 project.getInfo(), 132 project.getLogo(), 133 project.getCopyright(), 134 project.getLicenceText(), 135 project.getContributors(), 136 project); 137 } 138 139 145 public AboutDialog(final Dialog owner, 146 final String title, 147 final ProjectInfo project) 148 { 149 super(owner); 150 init(title, 151 project.getName(), 152 "Version " + project.getVersion(), 153 project.getInfo(), 154 project.getLogo(), 155 project.getCopyright(), 156 project.getLicenceText(), 157 project.getContributors(), 158 project); 159 } 160 161 174 private void init (final String title, 175 final String application, 176 final String version, 177 final String info, 178 final Image logo, 179 final String copyright, 180 final String licence, 181 final List contributors, 182 final ProjectInfo libraries) { 183 184 setTitle(title); 185 186 this.application = application; 187 this.version = version; 188 this.copyright = copyright; 189 this.info = info; 190 this.logo = logo; 191 this.contributors = contributors; 192 this.licence = licence; 193 194 final String baseName = "org.jfree.ui.about.resources.AboutResources"; 195 this.resources = ResourceBundle.getBundle(baseName); 196 197 final JPanel content = new JPanel (new BorderLayout ()); 198 content.setBorder(STANDARD_BORDER); 199 200 final JTabbedPane tabs = createTabs(libraries); 201 content.add(tabs); 202 setContentPane(content); 203 204 pack(); 205 206 } 207 208 213 public Dimension getPreferredSize() { 214 return PREFERRED_SIZE; 215 } 216 217 222 private JTabbedPane createTabs(final ProjectInfo info) { 223 224 final JTabbedPane tabs = new JTabbedPane (); 225 226 final JPanel aboutPanel = createAboutPanel(info); 227 aboutPanel.setBorder(AboutDialog.STANDARD_BORDER); 228 final String aboutTab = this.resources.getString("about-frame.tab.about"); 229 tabs.add(aboutTab, aboutPanel); 230 231 final JPanel systemPanel = new SystemPropertiesPanel(); 232 systemPanel.setBorder(AboutDialog.STANDARD_BORDER); 233 final String systemTab = this.resources.getString("about-frame.tab.system"); 234 tabs.add(systemTab, systemPanel); 235 236 return tabs; 237 238 } 239 240 246 private JPanel createAboutPanel(final ProjectInfo info) { 247 248 final JPanel about = new JPanel (new BorderLayout ()); 249 250 final JPanel details = new AboutPanel(this.application, this.version, this.copyright, this.info, 251 this.logo); 252 253 boolean includetabs = false; 254 final JTabbedPane tabs = new JTabbedPane (); 255 256 if (this.contributors != null) { 257 final JPanel contributorsPanel = new ContributorsPanel(this.contributors); 258 contributorsPanel.setBorder(AboutDialog.STANDARD_BORDER); 259 final String contributorsTab = this.resources.getString("about-frame.tab.contributors"); 260 tabs.add(contributorsTab, contributorsPanel); 261 includetabs = true; 262 } 263 264 if (this.licence != null) { 265 final JPanel licencePanel = createLicencePanel(); 266 licencePanel.setBorder(STANDARD_BORDER); 267 final String licenceTab = this.resources.getString("about-frame.tab.licence"); 268 tabs.add(licenceTab, licencePanel); 269 includetabs = true; 270 } 271 272 if (info != null) { 273 final JPanel librariesPanel = new LibraryPanel(info); 274 librariesPanel.setBorder(AboutDialog.STANDARD_BORDER); 275 final String librariesTab = this.resources.getString("about-frame.tab.libraries"); 276 tabs.add(librariesTab, librariesPanel); 277 includetabs = true; 278 } 279 280 about.add(details, BorderLayout.NORTH); 281 if (includetabs) { 282 about.add(tabs); 283 } 284 285 return about; 286 287 } 288 289 294 private JPanel createLicencePanel() { 295 296 final JPanel licencePanel = new JPanel (new BorderLayout ()); 297 final JTextArea area = new JTextArea (this.licence); 298 area.setLineWrap(true); 299 area.setWrapStyleWord(true); 300 area.setCaretPosition(0); 301 area.setEditable(false); 302 licencePanel.add(new JScrollPane (area)); 303 return licencePanel; 304 305 } 306 307 308 } 309 | Popular Tags |