List of utility methods to do JButton Settings
String | getSelectedButtonText(ButtonGroup buttonGroup) get Selected Button Text for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton button = buttons.nextElement(); if (button.isSelected()) { return button.getText(); return null; |
String | getSelectedButtonText(ButtonGroup buttonGroup) Determines the label of the current selected button. for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton button = buttons.nextElement(); if (button.isSelected()) { return button.getText(); return null; |
JToggleButton | getSoftToggleButton(String string) get Soft Toggle Button JToggleButton b = new JToggleButton(string); b.putClientProperty("JButton.buttonType", "segmentedRoundRect"); b.putClientProperty("JButton.segmentPosition", "only"); return b; |
int | getTextXOffset(AbstractButton c) get Text X Offset int xoffset = c.getPreferredSize().width; Border b = c.getBorder(); if (b != null) { xoffset -= b.getBorderInsets(c).right; String text = c.getText(); if (text != null) { xoffset -= c.getFontMetrics(c.getFont()).stringWidth(text); ... |
JToggleButton | getTogglableIconButton(ImageIcon icon) get Togglable Icon Button final ImageIcon selectedIcon = icon; final ImageIcon unselectedIcon = new ImageIcon(GrayFilter.createDisabledImage(icon.getImage())); final JToggleButton button = new JToggleButton(icon); button.setFocusable(false); button.setContentAreaFilled(false); button.setBorder(null); final Runnable setSelected = new Runnable() { @Override ... |
JButton | getWindowFileChooserOKButton(JFileChooser chooser) get Window File Chooser OK Button return (JButton) (((Container) ((Container) ((Container) chooser.getComponent(2)).getComponent(2))
.getComponent(4)).getComponent(1));
|
ButtonGroup | groupButtons(AbstractButton... buttons) group Buttons ButtonGroup group = new ButtonGroup(); for (AbstractButton button : buttons) { group.add(button); return group; |
ButtonGroup | groupButtons(final Container container, final boolean recursive) Groups all buttons inside this container and all subcontainers if requested and returns created button group. final ButtonGroup buttonGroup = new ButtonGroup(); groupButtons(container, recursive, buttonGroup); return buttonGroup; |
void | growFont(JComponent button) grow Font growFont(button, 1); |
boolean | hasIcon(AbstractButton button) Checks whether the specified button has associated icon. return (button.getIcon() != null);
|