List of utility methods to do JButton Create
JPanel | makeButtonPanel(Vector make Button Panel JPanel pane = new JPanel(); for (String s : names) { JButton b = makeButton(s, actionListener); pane.add(b); return pane; |
JButton | makeIconButton(Icon icon, String tooltip) make Icon Button JButton button = new JButton(icon); button.setToolTipText(tooltip); button.setBackground(BLUE8); button.setForeground(BLUE3); button.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, new Color(0, 0, 0, 0))); button.setFont(BIG); return button; |
JButton | makeNavigationButton(String actionCommand, String toolTipText, String altText) make Navigation Button JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); if (actionCommand.equals(CLOSE)) { ... |
JRadioButton | makeRadioButton(String text, String actionCommand, ButtonGroup buttonGroup, boolean selected) make Radio Button JRadioButton rb = new JRadioButton(text); rb.setSelected(selected); rb.setActionCommand(actionCommand); buttonGroup.add(rb); return rb; |
JToggleButton | makeToggleButton(final Object owner, final String id, final String altText, final int wpad, final int hpad) Constructs a JToggleButton with an icon from the given file id. final URL url = owner.getClass().getResource(id); ImageIcon icon = null; if (url != null) icon = new ImageIcon(url); JToggleButton button; if (icon == null) button = new JToggleButton(altText); else { ... |
JButton | newButton(String name, String text) new Button JButton button = new JButton(text); button.setName(name); return button; |
Component | newButton(String text, ActionListener... listeners) new Button return newButton(text, null, listeners);
|
JPopupMenu | newButtonPopup(final JToggleButton button) new Button Popup final JPopupMenu popup = new JPopupMenu(); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { if (button.isSelected()) { popup.show(button, 0, button.getHeight()); } else { popup.setVisible(false); }); popup.addPopupMenuListener(new PopupMenuListener() { public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) { button.setSelected(false); button.setEnabled(false); SwingUtilities.invokeLater(new Runnable() { public void run() { button.setEnabled(true); }); public void popupMenuWillBecomeVisible(PopupMenuEvent ev) { public void popupMenuCanceled(PopupMenuEvent ev) { }); return popup; |
Collection | newButtonsFrom(Collection new Buttons From Collection<JButton> buttons = new ArrayList<JButton>(); for (AbstractAction a : action) { buttons.add(new JButton(a)); return buttons; |
JButton | newJButton() new J Button final JButton[] jButton = new JButton[1]; try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { jButton[0] = new JButton(); }); ... |