1 48 49 package org.jfree.ui.about; 50 51 import java.awt.BorderLayout ; 52 import java.awt.Dimension ; 53 import java.awt.Image ; 54 import java.util.List ; 55 import java.util.ResourceBundle ; 56 import javax.swing.BorderFactory ; 57 import javax.swing.JFrame ; 58 import javax.swing.JPanel ; 59 import javax.swing.JScrollPane ; 60 import javax.swing.JTabbedPane ; 61 import javax.swing.JTextArea ; 62 import javax.swing.border.Border ; 63 64 69 public class AboutFrame extends JFrame { 70 71 72 public static final Dimension PREFERRED_SIZE = new Dimension (560, 360); 73 74 75 public static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(5, 5, 5, 5); 76 77 78 private ResourceBundle resources; 79 80 81 private String application; 82 83 84 private String version; 85 86 87 private String copyright; 88 89 90 private String info; 91 92 93 private Image logo; 94 95 96 private List contributors; 97 98 99 private String licence; 100 101 107 public AboutFrame(final String 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 134 public AboutFrame(final String title, 135 final String application, final String version, final String info, 136 final Image logo, 137 final String copyright, final String licence, 138 final List 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 baseName = "org.jfree.ui.about.resources.AboutResources"; 152 this.resources = ResourceBundle.getBundle(baseName); 153 154 final JPanel content = new JPanel (new BorderLayout ()); 155 content.setBorder(STANDARD_BORDER); 156 157 final JTabbedPane tabs = createTabs(project); 158 content.add(tabs); 159 setContentPane(content); 160 161 pack(); 162 163 } 164 165 170 public Dimension getPreferredSize() { 171 return PREFERRED_SIZE; 172 } 173 174 180 private JTabbedPane createTabs(final ProjectInfo project) { 181 182 final JTabbedPane tabs = new JTabbedPane (); 183 184 final JPanel aboutPanel = createAboutPanel(project); 185 aboutPanel.setBorder(AboutFrame.STANDARD_BORDER); 186 final String aboutTab = this.resources.getString("about-frame.tab.about"); 187 tabs.add(aboutTab, aboutPanel); 188 189 final JPanel systemPanel = new SystemPropertiesPanel(); 190 systemPanel.setBorder(AboutFrame.STANDARD_BORDER); 191 final String systemTab = this.resources.getString("about-frame.tab.system"); 192 tabs.add(systemTab, systemPanel); 193 194 return tabs; 195 196 } 197 198 205 private JPanel createAboutPanel(final ProjectInfo project) { 206 207 final JPanel about = new JPanel (new BorderLayout ()); 208 209 final JPanel details = new AboutPanel(this.application, this.version, this.copyright, this.info, 210 this.logo); 211 212 boolean includetabs = false; 213 final JTabbedPane tabs = new JTabbedPane (); 214 215 if (this.contributors != null) { 216 final JPanel contributorsPanel = new ContributorsPanel(this.contributors); 217 contributorsPanel.setBorder(AboutFrame.STANDARD_BORDER); 218 final String 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 licencePanel = createLicencePanel(); 225 licencePanel.setBorder(STANDARD_BORDER); 226 final String 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 librariesPanel = new LibraryPanel(project); 233 librariesPanel.setBorder(AboutFrame.STANDARD_BORDER); 234 final String 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 253 private JPanel createLicencePanel() { 254 255 final JPanel licencePanel = new JPanel (new BorderLayout ()); 256 final JTextArea area = new JTextArea (this.licence); 257 area.setLineWrap(true); 258 area.setWrapStyleWord(true); 259 area.setCaretPosition(0); 260 area.setEditable(false); 261 licencePanel.add(new JScrollPane (area)); 262 return licencePanel; 263 264 } 265 266 267 } 268 | Popular Tags |