List of utility methods to do JButton Settings
void | numberButtonGroup(ButtonGroup buttonGroup) number Button Group int entry = 0; Enumeration<AbstractButton> buttons = buttonGroup.getElements(); while (buttons.hasMoreElements()) { AbstractButton button = buttons.nextElement(); button.setActionCommand(Integer.toString(entry++)); |
void | opacityCheck(AbstractButton b) Sets the opacity of the specified button depending on the system look and Feel. if (b == null) return; b.setContentAreaFilled(!isMacOS()); |
void | paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex) paint Classic Text ButtonModel model = b.getModel(); Color color = b.getForeground(); if (model.isEnabled()) { if (!(b instanceof JMenuItem && model.isArmed()) && !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) { g.setColor(b.getForeground()); SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y); ... |
int | parseLevel(ButtonGroup buttonGroup) parse Level Enumeration<AbstractButton> buttonEnumeration = buttonGroup.getElements(); while (buttonEnumeration.hasMoreElements()) { AbstractButton abstractButton = buttonEnumeration.nextElement(); if (abstractButton.isSelected()) { String buttonText = abstractButton.getText(); final int index = buttonText.indexOf(" ("); if (index != -1) { buttonText = buttonText.substring(0, index); ... |
void | removeAllActionListeners(AbstractButton btn) removes all action listeners from the given button for (ActionListener al : btn.getActionListeners()) {
btn.removeActionListener(al);
|
void | removeButtonBorder(AbstractButton button) Removes the button border. button.setContentAreaFilled(false);
button.setMargin(new Insets(0, 0, 0, 0));
button.setBorder(BorderFactory.createEmptyBorder());
|
void | removeCloseButton(Component comp) Only works for default look and feel, where Swing creates a real close button. if (comp instanceof JMenu) { Component[] children = ((JMenu) comp).getMenuComponents(); for (int i = 0; i < children.length; ++i) { removeCloseButton(children[i]); } else if (comp instanceof AbstractButton) { Action action = ((AbstractButton) comp).getAction(); String cmd = (action == null) ? "" : action.toString(); ... |
ActionListener[] | removeListeners(AbstractButton button) Removes the listeners from the given AbstractButton ActionListener[] listeners = button.getActionListeners(); for (int i = 0; i < listeners.length; i++) { button.removeActionListener(listeners[i]); return listeners; |
void | scaleAllAbstractButtonIconsOf(Container container, int size) Resizes the icons of all the abstract buttons which are contained in a container. for (final Component c : container.getComponents()) { if (c instanceof AbstractButton) { final ImageIcon i = (ImageIcon) ((AbstractButton) c).getIcon(); if (i != null) { i.setImage(i.getImage().getScaledInstance(size, size, Image.SCALE_SMOOTH)); |
Icon | scaleButtonIcon(Icon icon, int size) scale Button Icon Icon result = icon; if (icon != null) { int h = icon.getIconHeight(); if ((size > (1.0 + ICON_SCALE_THRESHOLD) * h) || (size < (1.0 - ICON_SCALE_THRESHOLD) * h)) { int w = icon.getIconWidth(); BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); icon.paintIcon(new JButton(), image.getGraphics(), 0, 0); double ratio = (h == 0) ? 0.0 : (double) w / (double) h; ... |