1 46 47 package org.jfree.ui.about; 48 49 import java.awt.BorderLayout ; 50 import java.awt.event.ActionEvent ; 51 import java.awt.event.ActionListener ; 52 import java.util.ResourceBundle ; 53 54 import javax.swing.BorderFactory ; 55 import javax.swing.JButton ; 56 import javax.swing.JFrame ; 57 import javax.swing.JMenu ; 58 import javax.swing.JMenuBar ; 59 import javax.swing.JMenuItem ; 60 import javax.swing.JPanel ; 61 import javax.swing.WindowConstants ; 62 63 71 public class SystemPropertiesFrame extends JFrame implements ActionListener { 72 73 74 private static final String COPY_COMMAND = "COPY"; 75 76 77 private static final String CLOSE_COMMAND = "CLOSE"; 78 79 80 private SystemPropertiesPanel panel; 81 82 91 public SystemPropertiesFrame(final boolean menu) { 92 93 final String baseName = "org.jfree.ui.about.resources.AboutResources"; 94 final ResourceBundle resources = ResourceBundle.getBundle(baseName); 95 96 final String title = resources.getString("system-frame.title"); 97 setTitle(title); 98 99 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 100 101 if (menu) { 102 setJMenuBar(createMenuBar(resources)); 103 } 104 105 final JPanel content = new JPanel (new BorderLayout ()); 106 this.panel = new SystemPropertiesPanel(); 107 this.panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 108 109 content.add(this.panel, BorderLayout.CENTER); 110 111 final JPanel buttonPanel = new JPanel (new BorderLayout ()); 112 buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); 113 114 final String label = resources.getString("system-frame.button.close"); 115 final Character mnemonic = (Character ) resources.getObject("system-frame.button.close.mnemonic"); 116 final JButton closeButton = new JButton (label); 117 closeButton.setMnemonic(mnemonic.charValue()); 118 119 closeButton.setActionCommand(CLOSE_COMMAND); 120 closeButton.addActionListener(this); 121 122 buttonPanel.add(closeButton, BorderLayout.EAST); 123 content.add(buttonPanel, BorderLayout.SOUTH); 124 125 setContentPane(content); 126 127 } 128 129 134 public void actionPerformed(final ActionEvent e) { 135 136 final String command = e.getActionCommand(); 137 if (command.equals(CLOSE_COMMAND)) { 138 dispose(); 139 } 140 else if (command.equals(COPY_COMMAND)) { 141 this.panel.copySystemPropertiesToClipboard(); 142 } 143 144 } 145 146 147 154 private JMenuBar createMenuBar(final ResourceBundle resources) { 155 156 final JMenuBar menuBar = new JMenuBar (); 157 158 String label = resources.getString("system-frame.menu.file"); 159 Character mnemonic = (Character ) resources.getObject("system-frame.menu.file.mnemonic"); 160 final JMenu fileMenu = new JMenu (label, true); 161 fileMenu.setMnemonic(mnemonic.charValue()); 162 163 label = resources.getString("system-frame.menu.file.close"); 164 mnemonic = (Character ) resources.getObject("system-frame.menu.file.close.mnemonic"); 165 final JMenuItem closeItem = new JMenuItem (label, mnemonic.charValue()); 166 closeItem.setActionCommand(CLOSE_COMMAND); 167 168 closeItem.addActionListener(this); 169 fileMenu.add(closeItem); 170 171 label = resources.getString("system-frame.menu.edit"); 172 mnemonic = (Character ) resources.getObject("system-frame.menu.edit.mnemonic"); 173 final JMenu editMenu = new JMenu (label); 174 editMenu.setMnemonic(mnemonic.charValue()); 175 176 label = resources.getString("system-frame.menu.edit.copy"); 177 mnemonic = (Character ) resources.getObject("system-frame.menu.edit.copy.mnemonic"); 178 final JMenuItem copyItem = new JMenuItem (label, mnemonic.charValue()); 179 copyItem.setActionCommand(COPY_COMMAND); 180 copyItem.addActionListener(this); 181 editMenu.add(copyItem); 182 183 menuBar.add(fileMenu); 184 menuBar.add(editMenu); 185 return menuBar; 186 187 } 188 189 } 190 | Popular Tags |