List of usage examples for org.jfree.ui RefineryUtilities createJButton
public static JButton createJButton(final String label, final Font font)
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Creates a tabbed pane containing descriptions of the demo charts. * * @param resources localised resources. * * @return a tabbed pane./* ww w.jav a 2s . c o m*/ */ 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; }