List of utility methods to do JButton Settings
Insets | getDefaultFatButtonMargin() get Default Fat Button Margin if (isGTKLaF()) { return new Insets(0, 2, 0, 2); return new Insets(2, 4, 2, 4); |
int | getHudControlShadowSize(AbstractButton button) Gets the number of pixels that a HUD style widget's shadow takes up. return 2;
|
Icon | getIcon(AbstractButton b) Returns the current icon for the specified button. Icon icon = b.getIcon(); if (icon == null) return null; ButtonModel model = b.getModel(); Icon tmpIcon = null; if (icon != null) { if (!model.isEnabled()) { if (model.isSelected()) { ... |
List | getListenedButtonsFor(Container c) get Listened Buttons For List<JButton> filter = null; List<JButton> result = new ArrayList<JButton>(); searchFor(c, JButton.class, filter = new ArrayList<JButton>(), null); for (JButton button : filter) { if (button.getActionListeners().length > 0) { result.add(button); return result; |
JButton | getMonospaceButton(final String text, final int size) Returns a JButton with monospaced text. Font font = new Font(Font.MONOSPACED, Font.PLAIN, size); JButton button = new JButton(text); button.setFont(font); return button; |
Dimension | getPreferredButtonSize(AbstractButton b, int textIconGap) Determines the preferred width and height of an AbstractButton, given the gap between the button’s text and icon. Rectangle contentRect; Rectangle viewRect; Rectangle iconRect = new Rectangle(); Rectangle textRect = new Rectangle(); Insets insets = b.getInsets(); Insets margin = b.getMargin(); viewRect = new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE); SwingUtilities.layoutCompoundLabel(b, ... |
Dimension | getPreferredButtonSize(AbstractButton b, int textIconGap) get Preferred Button Size if (b.getComponentCount() > 0) { return null; Icon icon = (Icon) b.getIcon(); String text = b.getText(); Font font = b.getFont(); FontMetrics fm = b.getFontMetrics(font); Rectangle iconR = new Rectangle(); ... |
ImageIcon | getPressedButtonIcon(int x, int y) get Pressed Button Icon if (PressedButton == null) { PressedButton = new ImageIcon(IMAGE_FOLDER + PRESSED_BUTTON_IMAGE); return prepareImage(PressedButton, x, y); |
Border | getRadioButtonBorder(int fontSize, boolean ltr) Returns the border for radio buttons under the specified font size. Border checkBoxBorder = getCheckBoxBorder(fontSize, ltr); Insets checkBoxInsets = checkBoxBorder.getBorderInsets(null); return new BorderUIResource.EmptyBorderUIResource(checkBoxInsets.top, checkBoxInsets.left - (ltr ? 0 : 2), checkBoxInsets.bottom, checkBoxInsets.right - (ltr ? 2 : 0)); |
AbstractButton | getSelectedButton(ButtonGroup group) get Selected Button Enumeration<AbstractButton> buttons = group.getElements(); while (buttons.hasMoreElements()) { AbstractButton button = buttons.nextElement(); if (button.isSelected()) { return button; return null; ... |