⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jfreechartdemo.java

📁 大家打开看看啊, 很有用的东西
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                                   JOptionPane.QUESTION_MESSAGE);
        if (result == JOptionPane.YES_OPTION) {
            dispose();
            System.exit(0);
        }
    }

    /**
     * Displays information about the application.
     */
    private void about() {

        String title = this.resources.getString("about.title");
        //String versionLabel = this.resources.getString("about.version.label");
        if (aboutFrame == null) {
            aboutFrame = new AboutFrame(title, JFreeChart.INFO);
            aboutFrame.pack();
            RefineryUtilities.centerFrameOnScreen(aboutFrame);
        }
        aboutFrame.show();
        aboutFrame.requestFocus();

    }

    /**
     * The starting point for the demonstration application.
     *
     * @param args  ignored.
     */
    public static void main(String[] args) {

        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(WindowEvent e) {
    }

    /**
     * Clears the reference to the print preview frames when they are closed.
     *
     * @param e  the event.
     */
    public void windowClosed(WindowEvent e) {

        if (e.getWindow() == this.aboutFrame) {
            aboutFrame = null;
        }

    }

    /**
     * Required for WindowListener interface, but not used by this class.
     *
     * @param e  the event.
     */
    public void windowClosing(WindowEvent e) {
    }

    /**
     * Required for WindowListener interface, but not used by this class.
     *
     * @param e  the event.
     */
    public void windowDeactivated(WindowEvent e) {
    }

    /**
     * Required for WindowListener interface, but not used by this class.
     *
     * @param e  the event.
     */
    public void windowDeiconified(WindowEvent e) {
    }

    /**
     * Required for WindowListener interface, but not used by this class.
     *
     * @param e  the event.
     */
    public void windowIconified(WindowEvent e) {
    }

    /**
     * Required for WindowListener interface, but not used by this class.
     *
     * @param e  the event.
     */
    public void windowOpened(WindowEvent e) {
    }

    /**
     * Creates a menubar.
     *
     * @param resources  localised resources.
     *
     * @return the menu bar.
     */
    private JMenuBar createMenuBar(ResourceBundle resources) {

        // create the menus
        JMenuBar menuBar = new JMenuBar();

        String label;
        Character mnemonic;

        // first the file menu
        label = resources.getString("menu.file");
        mnemonic = (Character) resources.getObject("menu.file.mnemonic");
        JMenu fileMenu = new JMenu(label, true);
        fileMenu.setMnemonic(mnemonic.charValue());

        label = resources.getString("menu.file.exit");
        mnemonic = (Character) resources.getObject("menu.file.exit.mnemonic");
        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");
        JMenu helpMenu = new JMenu(label);
        helpMenu.setMnemonic(mnemonic.charValue());

        label = resources.getString("menu.help.about");
        mnemonic = (Character) resources.getObject("menu.help.about.mnemonic");
        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(ResourceBundle resources) {

        Font font = new Font("Dialog", Font.PLAIN, 12);
        JTabbedPane tabs = new JTabbedPane();

        int tab = 1;
        Vector titles = new Vector(0);
        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();
        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) {
            panels[i] = new JPanel();
            panels[i].setLayout(new LCBLayout(20));
            panels[i].setPreferredSize(new Dimension(360, 20));
            panels[i].setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
            tabs.add(tabTitles[i], new JScrollPane(panels[i]));
        }

        String description;
        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 >= panels.length)) {
                    tab = 0;
                }

                System.out.println("Demo : adding " + CHART_COMMANDS[i][0] + " to panel " + tab);
                panels[tab].add(RefineryUtilities.createJLabel(title, font));
                panels[tab].add(new DescriptionPanel(new JTextArea(description)));
                b1 = RefineryUtilities.createJButton(buttonText, font);
                b1.setActionCommand(CHART_COMMANDS[i][0]);
                b1.addActionListener(this);
                panels[tab].add(b1);
            }
        }

        return tabs;

    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -