Java Code Examples for javax.swing.AbstractButton#isEnabled()
The following examples show how to use
javax.swing.AbstractButton#isEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RapidLookTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Drasw a button in a toolbar. * * @param b * the button * @param g * the graphics instance */ public static void drawToolbarButton(Graphics g, AbstractButton b) { if (!b.isEnabled()) { return; } if (b.getModel().isSelected() && b.isRolloverEnabled() || b.getModel().isPressed() && b.getModel().isArmed() && b.isRolloverEnabled()) { if (b.isContentAreaFilled()) { drawButton(b, g, createShapeForButton(b)); } if (b.isBorderPainted()) { drawButtonBorder(b, g, createBorderShapeForButton(b)); } } else if (b.getModel().isRollover() && b.isRolloverEnabled()) { if (b.isBorderPainted()) { drawButtonBorder(b, g, createBorderShapeForButton(b)); } } }
Example 2
Source File: QButtonUI.java From pumpernickel with MIT License | 6 votes |
@Override protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { // this hack helps us render a button in a different enabled state // than what it really is: ButtonState.Boolean state = (ButtonState.Boolean) b .getClientProperty(PROPERTY_BOOLEAN_BUTTON_STATE); if (state != null && state.isEnabled() != b.isEnabled()) { scratchButton.setText(b.getText()); scratchButton.setDisplayedMnemonicIndex(b .getDisplayedMnemonicIndex()); scratchButton.setForeground(b.getForeground()); scratchButton.setFont(b.getFont()); scratchButton.setBackground(b.getBackground()); scratchButton.setEnabled(state.isEnabled()); super.paintText(g, scratchButton, textRect, text); return; } super.paintText(g, b, textRect, text); }
Example 3
Source File: SearchButton.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void mouseEntered(MouseEvent evt) { Object src = evt.getSource(); if (src instanceof AbstractButton) { AbstractButton button = (AbstractButton) evt.getSource(); if (button.isEnabled()) { button.setContentAreaFilled(true); button.setBorderPainted(true); } } }
Example 4
Source File: ToolButtonFactory.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void setSelectedState(AbstractButton b) { if (b.isEnabled()) { b.setBorderPainted(true); b.setBackground(SELECTED_BACKGROUND_COLOR); } else { b.setBorderPainted(false); b.setBackground(getDefaultBackground().darker()); } }
Example 5
Source File: ButtonBorder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (c instanceof AbstractButton) { AbstractButton b = (AbstractButton)c; ButtonModel model = b.getModel(); boolean isPressed; boolean isRollover; boolean isEnabled; isPressed = model.isPressed() && model.isArmed(); isRollover = b.isRolloverEnabled() && model.isRollover(); isEnabled = b.isEnabled(); if (!isEnabled) { paintDisabled(b, g, x, y, width, height); } else { if (isPressed) { paintPressed(b, g, x, y, width, height); } else if (isRollover) { paintRollover(b, g, x, y, width, height); } else { paintNormal(b, g, x, y, width, height); } } } }
Example 6
Source File: SeaGlassButtonUI.java From seaglass with Apache License 2.0 | 5 votes |
/** * Returns the Icon used in calculating the pref/min/max size. * * @param b DOCUMENT ME! * * @return DOCUMENT ME! */ protected Icon getSizingIcon(AbstractButton b) { // NOTE: this is slightly different than BasicButtonUI, where it // would just use getIcon, but this should be ok. Icon icon = (b.isEnabled() || b.getDisabledIcon() == null) ? b.getIcon() : b.getDisabledIcon(); if (icon == null) { icon = getDefaultIcon(b); } return icon; }
Example 7
Source File: StyledCheckBoxUI.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override protected void paintText(Graphics graphics, AbstractButton button, Rectangle textRect, String text) { if (button.isEnabled()) { super.paintText(graphics, button, textRect, text); } else { int shift = graphics.getFontMetrics().getAscent(); StyleUtil.paintDisabledText(style, graphics, text, textRect.x, textRect.y + shift); } }
Example 8
Source File: StyledButtonUI.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override protected void paintText(Graphics graphics, AbstractButton button, Rectangle textRect, String text) { if (button.isEnabled()) { super.paintText(graphics, button, textRect, text); } else { int shift = graphics.getFontMetrics().getAscent(); StyleUtil.paintDisabledText(style, graphics, text, textRect.x, textRect.y + shift); } }
Example 9
Source File: RapidLookTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Draws the given button border with the specified shape. * * @param b * @param g * @param shape */ public static void drawButtonBorder(AbstractButton b, Graphics g, Shape shape) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); boolean darkBorder = Boolean.parseBoolean(String.valueOf(b.getClientProperty(RapidLookTools.PROPERTY_BUTTON_DARK_BORDER))); if (darkBorder) { if (b.isEnabled()) { if (b.hasFocus()) { g2.setColor(Colors.BUTTON_BORDER_DARK_FOCUS); } else { g2.setColor(Colors.BUTTON_BORDER_DARK); } } else { g2.setColor(Colors.BUTTON_BORDER_DARK_DISABLED); } } else { if (b.isEnabled()) { if (b.hasFocus()) { g2.setColor(Colors.BUTTON_BORDER_FOCUS); } else { g2.setColor(Colors.BUTTON_BORDER); } } else { g2.setColor(Colors.BUTTON_BORDER_DISABLED); } } g2.draw(shape); }
Example 10
Source File: DoubleClickListener.java From pumpernickel with MIT License | 5 votes |
/** * When a double-click is observed a button is clicked. * * @param button * when a double-click is observed this button's * <code>doClick()</code> method is invoked if it is enabled. */ public DoubleClickListener(final AbstractButton button) { this(new Runnable() { public void run() { if (button.isEnabled()) button.doClick(); } }); if (button == null) throw new NullPointerException(); }
Example 11
Source File: TransparentToolBar.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void refresh(final AbstractButton b) { b.setBackground(UISupport.getDefaultBackground()); boolean hovered = Boolean.TRUE.equals(b.getClientProperty(PROP_HOVERED)); boolean filled = b.isEnabled() && (hovered || b.isSelected() || b.isFocusOwner()); b.setOpaque(filled); b.setContentAreaFilled(filled); b.repaint(); }
Example 12
Source File: TransparentToolBar.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void refresh(final AbstractButton b) { b.setBackground(UIUtils.getProfilerResultsBackground()); boolean hovered = Boolean.TRUE.equals(b.getClientProperty(PROP_HOVERED)); boolean filled = b.isEnabled() && (hovered || b.isSelected() || b.isFocusOwner()); b.setOpaque(filled); b.setContentAreaFilled(filled); b.repaint(); }
Example 13
Source File: ButtonBorder.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (c instanceof AbstractButton) { AbstractButton b = (AbstractButton)c; ButtonModel model = b.getModel(); boolean isPressed; boolean isRollover; boolean isEnabled; isPressed = model.isPressed() && model.isArmed(); isRollover = b.isRolloverEnabled() && model.isRollover(); isEnabled = b.isEnabled(); if (!isEnabled) { paintDisabled(b, g, x, y, width, height); } else { if (isPressed) { paintPressed(b, g, x, y, width, height); } else if (isRollover) { paintRollover(b, g, x, y, width, height); } else { paintNormal(b, g, x, y, width, height); } } } }
Example 14
Source File: FloatingButtonEnabler.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Triggers the drawing of the border when the mouse entered the button area. * * @param e the mouse event. */ public void mouseEntered(final MouseEvent e) { if (e.getSource() instanceof AbstractButton) { final AbstractButton button = (AbstractButton) e.getSource(); if (button.isEnabled()) { button.setBorderPainted(true); } } }
Example 15
Source File: DataViewUI.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void mouseEntered(MouseEvent evt) { Object src = evt.getSource(); if (src instanceof AbstractButton) { AbstractButton button = (AbstractButton) evt.getSource(); if (button.isEnabled()) { button.setContentAreaFilled(true); button.setBorderPainted(true); } } }
Example 16
Source File: NbEditorToolBar.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void mouseEntered(MouseEvent evt) { Object src = evt.getSource(); if (src instanceof AbstractButton) { AbstractButton button = (AbstractButton)evt.getSource(); if (button.isEnabled()) { button.setContentAreaFilled(true); button.setBorderPainted(true); } } }
Example 17
Source File: TransparentToolBar.java From netbeans with Apache License 2.0 | 5 votes |
private void refresh(final AbstractButton b) { b.setBackground(UIUtils.getProfilerResultsBackground()); boolean hovered = Boolean.TRUE.equals(b.getClientProperty(PROP_HOVERED)); boolean filled = b.isEnabled() && (hovered || b.isSelected() || b.isFocusOwner()); b.setOpaque(filled); b.setContentAreaFilled(filled); b.repaint(); }
Example 18
Source File: RapidLookTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
/** * Draws the given button with the specified shape. * * @param b * @param g * @param shape */ public static void drawButton(AbstractButton b, Graphics g, Shape shape) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int h = (int) shape.getBounds().getHeight(); ColorUIResource colorGradientStart; ColorUIResource colorGradientEnd; boolean highlighted = Boolean.parseBoolean(String.valueOf(b.getClientProperty(PROPERTY_BUTTON_HIGHLIGHT))); boolean highlightedDark = Boolean.parseBoolean(String.valueOf(b.getClientProperty(PROPERTY_BUTTON_HIGHLIGHT_DARK))); boolean highlightedWhite = Boolean.parseBoolean(String.valueOf(b.getClientProperty(PROPERTY_BUTTON_HIGHLIGHT_WHITE))); if (highlighted) { if (b.isEnabled()) { if (b.getModel().isPressed() || b.getModel().isSelected()) { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_PRESSED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_PRESSED_GRADIENT_END; } else if (b.getModel().isRollover()) { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_ROLLOVER_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_ROLLOVER_GRADIENT_END; } else { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_GRADIENT_END; } } else { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DISABLED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DISABLED_GRADIENT_END; } } else if (highlightedDark) { if (b.isEnabled()) { if (b.getModel().isPressed() || b.getModel().isSelected()) { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_PRESSED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_PRESSED_GRADIENT_END; } else if (b.getModel().isRollover()) { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_ROLLOVER_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_ROLLOVER_GRADIENT_END; } else { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_GRADIENT_END; } } else { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_DISABLED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_DARK_DISABLED_GRADIENT_END; } } else if (highlightedWhite) { if (b.isEnabled()) { if (b.getModel().isPressed() || b.getModel().isSelected()) { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_PRESSED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_PRESSED_GRADIENT_END; } else if (b.getModel().isRollover()) { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_ROLLOVER_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_ROLLOVER_GRADIENT_END; } else { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_GRADIENT_END; } } else { colorGradientStart = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_DISABLED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_HIGHLIGHTED_WHITE_DISABLED_GRADIENT_END; } } else { if (b.isEnabled()) { if (b.getModel().isPressed() || b.getModel().isSelected()) { colorGradientStart = Colors.BUTTON_BACKGROUND_PRESSED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_PRESSED_GRADIENT_END; } else if (b.getModel().isRollover()) { colorGradientStart = Colors.BUTTON_BACKGROUND_ROLLOVER_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_ROLLOVER_GRADIENT_END; } else { colorGradientStart = Colors.BUTTON_BACKGROUND_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_GRADIENT_END; } } else { colorGradientStart = Colors.BUTTON_BACKGROUND_DISABLED_GRADIENT_START; colorGradientEnd = Colors.BUTTON_BACKGROUND_DISABLED_GRADIENT_END; } } Paint gp = new GradientPaint(0, 0, colorGradientStart, 0, h, colorGradientEnd); g2.setPaint(gp); g2.fill(shape); }
Example 19
Source File: ToolButtonFactory.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void setRolloverStateState(AbstractButton b) { if (b.isEnabled()) { b.setBorderPainted(true); b.setBackground(ROLLOVER_BACKGROUND_COLOR); } }