📄 jfreechartdemo.java
字号:
dispose(); System.exit(0); } } /** * Displays information about the application. */ private void about() { final String title = this.resources.getString("about.title"); //String versionLabel = this.resources.getString("about.version.label"); if (this.aboutFrame == null) { this.aboutFrame = new AboutFrame(title, JFreeChart.INFO); this.aboutFrame.pack(); RefineryUtilities.centerFrameOnScreen(this.aboutFrame); } this.aboutFrame.setVisible(true); this.aboutFrame.requestFocus(); } /** * The starting point for the demonstration application. * * @param args ignored. */ public static void main(final String[] args) { final JFreeChartDemo f = new JFreeChartDemo(); f.pack(); RefineryUtilities.centerFrameOnScreen(f); f.setVisible(true); } /** * Required for WindowListener interface, but not used by this class. * * @param e the event. */ public void windowActivated(final WindowEvent e) { // not used } /** * Clears the reference to the print preview frames when they are closed. * * @param e the event. */ public void windowClosed(final WindowEvent e) { if (e.getWindow() == this.aboutFrame) { this.aboutFrame = null; } } /** * Required for WindowListener interface, but not used by this class. * * @param e the event. */ public void windowClosing(final WindowEvent e) { // ignored } /** * Required for WindowListener interface, but not used by this class. * * @param e the event. */ public void windowDeactivated(final WindowEvent e) { // ignored } /** * Required for WindowListener interface, but not used by this class. * * @param e the event. */ public void windowDeiconified(final WindowEvent e) { // ignored } /** * Required for WindowListener interface, but not used by this class. * * @param e the event. */ public void windowIconified(final WindowEvent e) { // ignored } /** * Required for WindowListener interface, but not used by this class. * * @param e the event. */ public void windowOpened(final WindowEvent e) { // ignored } /** * Creates a menubar. * * @param resources localised resources. * * @return the menu bar. */ private JMenuBar createMenuBar(final ResourceBundle resources) { // create the menus final JMenuBar menuBar = new JMenuBar(); String label; Character mnemonic; // first the file menu label = resources.getString("menu.file"); mnemonic = (Character) resources.getObject("menu.file.mnemonic"); final JMenu fileMenu = new JMenu(label, true); fileMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.file.exit"); mnemonic = (Character) resources.getObject("menu.file.exit.mnemonic"); final JMenuItem exitItem = new JMenuItem(label, mnemonic.charValue()); exitItem.setActionCommand(EXIT_COMMAND); exitItem.addActionListener(this); fileMenu.add(exitItem); // then the help menu label = resources.getString("menu.help"); mnemonic = (Character) resources.getObject("menu.help.mnemonic"); final JMenu helpMenu = new JMenu(label); helpMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.help.about"); mnemonic = (Character) resources.getObject("menu.help.about.mnemonic"); final JMenuItem aboutItem = new JMenuItem(label, mnemonic.charValue()); aboutItem.setActionCommand(ABOUT_COMMAND); aboutItem.addActionListener(this); helpMenu.add(aboutItem); // finally, glue together the menu and return it menuBar.add(fileMenu); menuBar.add(helpMenu); return menuBar; } /** * Creates a tabbed pane containing descriptions of the demo charts. * * @param resources localised resources. * * @return a tabbed pane. */ private JTabbedPane createTabbedPane(final ResourceBundle resources) { final Font font = new Font("Dialog", Font.PLAIN, 12); final JTabbedPane tabs = new JTabbedPane(); int tab = 1; final Vector titles = new Vector(0); final String[] tabTitles; String title = null; while (tab > 0) { try { title = resources.getString("tabs." + tab); if (title != null) { titles.add(title); } else { tab = -1; } ++tab; } catch (Exception ex) { tab = -1; } } if (titles.size() == 0) { titles.add("Default"); } tab = titles.size(); this.panels = new JPanel[tab]; tabTitles = new String[tab]; --tab; for (; tab >= 0; --tab) { title = titles.get(tab).toString(); tabTitles[tab] = title; } titles.removeAllElements(); for (int i = 0; i < tabTitles.length; ++i) { this.panels[i] = new JPanel(); this.panels[i].setLayout(new LCBLayout(20)); this.panels[i].setPreferredSize(new Dimension(360, 20)); this.panels[i].setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); tabs.add(tabTitles[i], new JScrollPane(this.panels[i])); } String description; final String buttonText = resources.getString("charts.display"); JButton b1; // Load the CHARTS ... String usage = null; for (int i = 0; i <= CHART_COMMANDS.length - 1; ++i) { try { usage = resources.getString(CHART_COMMANDS[i][2] + ".usage"); } catch (Exception ex) { usage = null; } if ((usage == null) || usage.equalsIgnoreCase("All") || usage.equalsIgnoreCase("Swing")) { title = resources.getString(CHART_COMMANDS[i][2] + ".title"); description = resources.getString(CHART_COMMANDS[i][2] + ".description"); try { tab = Integer.parseInt(resources.getString(CHART_COMMANDS[i][2] + ".tab")); --tab; } catch (Exception ex) { System.err.println("Demo : Error retrieving tab identifier for chart " + CHART_COMMANDS[i][2]); System.err.println("Demo : Error = " + ex.getMessage()); tab = 0; } if ((tab < 0) || (tab >= this.panels.length)) { tab = 0; } System.out.println("Demo : adding " + CHART_COMMANDS[i][0] + " to panel " + tab); this.panels[tab].add(RefineryUtilities.createJLabel(title, font)); this.panels[tab].add(new DescriptionPanel(new JTextArea(description))); b1 = RefineryUtilities.createJButton(buttonText, font); b1.setActionCommand(CHART_COMMANDS[i][0]); b1.addActionListener(this); this.panels[tab].add(b1); } } return tabs; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -