Java Code Examples for javax.swing.JComponent#isEnabled()
The following examples show how to use
javax.swing.JComponent#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: SeaGlassMenuUI.java From seaglass with Apache License 2.0 | 6 votes |
private int getComponentState(JComponent c) { int state; if (!c.isEnabled()) { return DISABLED; } if (menuItem.isArmed()) { state = MOUSE_OVER; } else { state = SeaGlassLookAndFeel.getComponentState(c); } if (menuItem.isSelected()) { state |= SELECTED; } return state; }
Example 2
Source File: FlatToggleButtonUI.java From FlatLaf with Apache License 2.0 | 5 votes |
@Override protected Color getForeground( JComponent c ) { if( c.isEnabled() && ((AbstractButton)c).isSelected() && !isToolBarButton( c ) ) return selectedForeground; return super.getForeground( c ); }
Example 3
Source File: SeaGlassMenuItemUI.java From seaglass with Apache License 2.0 | 5 votes |
private int getComponentState(JComponent c) { int state; if (!c.isEnabled()) { state = DISABLED; } else if (menuItem.isArmed()) { state = MOUSE_OVER; } else { state = SeaGlassLookAndFeel.getComponentState(c); } if (menuItem.isSelected()) { state |= SELECTED; } return state; }
Example 4
Source File: PToolTipUI.java From PolyGlot with MIT License | 5 votes |
/** * Invoked when the <code>JComponent</code> associated with the * <code>JToolTip</code> has changed, or at initialization time. This * should update any state dependant upon the <code>JComponent</code>. * * @param c the JToolTip the JComponent has changed on. */ private void componentChanged(JComponent c) { JComponent comp = ((JToolTip)c).getComponent(); if (comp != null && !(comp.isEnabled())) { // For better backward compatibility, only install inactive // properties if they are defined. if (UIManager.getBorder("ToolTip.borderInactive") != null) { LookAndFeel.installBorder(c, "ToolTip.borderInactive"); } else { LookAndFeel.installBorder(c, "ToolTip.border"); } if (UIManager.getColor("ToolTip.backgroundInactive") != null) { LookAndFeel.installColors(c,"ToolTip.backgroundInactive", "ToolTip.foregroundInactive"); } else { LookAndFeel.installColors(c,"ToolTip.background", "ToolTip.foreground"); } } else { LookAndFeel.installBorder(c, "ToolTip.border"); LookAndFeel.installColors(c, "ToolTip.background", "ToolTip.foreground"); } }
Example 5
Source File: DataObjectTransferHandler.java From nextreports-designer with Apache License 2.0 | 5 votes |
@Override public boolean canImport(JComponent c, DataFlavor[] dataFlavors) { if (c.isEnabled() && (c instanceof JTable)) { for (DataFlavor dataFlavor : dataFlavors) { if (dataFlavor.equals(this.dataFlavor)) { return true; } } } return false; }
Example 6
Source File: SeaGlassTextFieldUI.java From seaglass with Apache License 2.0 | 5 votes |
/** * DOCUMENT ME! * * @param c DOCUMENT ME! * @param region DOCUMENT ME! * * @return DOCUMENT ME! */ private int getComponentState(JComponent c, Region region) { if (region == SeaGlassRegion.SEARCH_FIELD_CANCEL_BUTTON && c.isEnabled()) { if (((JTextComponent) c).getText().length() == 0) { return DISABLED; } else if (isCancelArmed) { return PRESSED; } return ENABLED; } return SeaGlassLookAndFeel.getComponentState(c); }
Example 7
Source File: SeaGlassTabbedPaneUI.java From seaglass with Apache License 2.0 | 5 votes |
/** * Get the state for the specified tab's close button. * * @param c the tabbed pane. * @param tabIndex the index of the tab. * @param tabIsMousedOver TODO * * @return the close button state. */ public int getCloseButtonState(JComponent c, int tabIndex, boolean tabIsMousedOver) { if (!c.isEnabled()) { return DISABLED; } else if (tabIndex == closeButtonArmedIndex) { return PRESSED; } else if (tabIndex == closeButtonHoverIndex) { return FOCUSED; } else if (tabIsMousedOver) { return MOUSE_OVER; } return ENABLED; }
Example 8
Source File: MetalScrollBarUI.java From Bytecoder with Apache License 2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 9
Source File: MetalScrollBarUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 10
Source File: AquaScrollRegionBorder.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
protected State getState(final JComponent c) { if (!AquaFocusHandler.isActive(c)) return State.INACTIVE; if (!c.isEnabled()) return State.DISABLED; return State.ACTIVE; }
Example 11
Source File: MetalScrollBarUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 12
Source File: IntroduceMethodPanel.java From netbeans with Apache License 2.0 | 4 votes |
private boolean isAvailable(JComponent c) { return c.isVisible() && c.isEnabled(); }
Example 13
Source File: MetalScrollBarUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 14
Source File: MetalScrollBarUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 15
Source File: SeaGlassButtonUI.java From seaglass with Apache License 2.0 | 4 votes |
/** * Returns the current state of the passed in <code>AbstractButton</code>. * * @param c the button component. * * @return the button's state. */ private int getComponentState(JComponent c) { int state = ENABLED; if (!c.isEnabled()) { state = DISABLED; } if (SeaGlassLookAndFeel.selectedUI == this) { return SeaGlassLookAndFeel.selectedUIState | SynthConstants.ENABLED; } AbstractButton button = (AbstractButton) c; ButtonModel model = button.getModel(); if (model.isPressed()) { if (model.isArmed()) { state = PRESSED; } else { state = MOUSE_OVER; } } if (model.isRollover()) { state |= MOUSE_OVER; } if (model.isSelected()) { state |= SELECTED; } if (c.isFocusOwner() && button.isFocusPainted()) { state |= FOCUSED; } if ((c instanceof JButton) && ((JButton) c).isDefaultButton()) { state |= DEFAULT; } return state; }
Example 16
Source File: MetalScrollBarUI.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 17
Source File: AquaScrollRegionBorder.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
protected State getState(final JComponent c) { if (!AquaFocusHandler.isActive(c)) return State.INACTIVE; if (!c.isEnabled()) return State.DISABLED; return State.ACTIVE; }
Example 18
Source File: AquaScrollRegionBorder.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected State getState(final JComponent c) { if (!AquaFocusHandler.isActive(c)) return State.INACTIVE; if (!c.isEnabled()) return State.DISABLED; return State.ACTIVE; }
Example 19
Source File: MetalScrollBarUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds ) { if (!c.isEnabled()) { return; } if (MetalLookAndFeel.usingOcean()) { oceanPaintThumb(g, c, thumbBounds); return; } boolean leftToRight = MetalUtils.isLeftToRight(c); g.translate( thumbBounds.x, thumbBounds.y ); if ( scrollbar.getOrientation() == JScrollBar.VERTICAL ) { if ( !isFreeStanding ) { thumbBounds.width += 2; if ( !leftToRight ) { g.translate( -1, 0 ); } } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 2); bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 ); bumps.paintIcon( c, g, 3, 4 ); if ( !isFreeStanding ) { thumbBounds.width -= 2; if ( !leftToRight ) { g.translate( 1, 0 ); } } } else // HORIZONTAL { if ( !isFreeStanding ) { thumbBounds.height += 2; } g.setColor( thumbColor ); g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 ); g.setColor( thumbShadow ); drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2); g.setColor( thumbHighlightColor ); drawHLine(g, 1, thumbBounds.width - 3, 1); drawVLine(g, 1, 1, thumbBounds.height - 3); bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 ); bumps.paintIcon( c, g, 4, 3 ); if ( !isFreeStanding ) { thumbBounds.height -= 2; } } g.translate( -thumbBounds.x, -thumbBounds.y ); }
Example 20
Source File: FlatDatePickerUI.java From FlatLaf with Apache License 2.0 | 4 votes |
@Override public void update( Graphics g, JComponent c ) { // fill background if opaque to avoid garbage if user sets opaque to true if( c.isOpaque() ) FlatUIUtils.paintParentBackground( g, c ); Graphics2D g2 = (Graphics2D) g; FlatUIUtils.setRenderingHints( g2 ); int width = c.getWidth(); int height = c.getHeight(); float focusWidth = FlatUIUtils.getBorderFocusWidth( c ); float arc = FlatUIUtils.getBorderArc( c ); int arrowX = popupButton.getX(); int arrowWidth = popupButton.getWidth(); boolean enabled = c.isEnabled(); boolean isLeftToRight = c.getComponentOrientation().isLeftToRight(); // paint background g2.setColor( enabled ? c.getBackground() : disabledBackground ); FlatUIUtils.paintComponentBackground( g2, 0, 0, width, height, focusWidth, arc ); // paint arrow button background if( enabled ) { g2.setColor( buttonBackground ); Shape oldClip = g2.getClip(); if( isLeftToRight ) g2.clipRect( arrowX, 0, width - arrowX, height ); else g2.clipRect( 0, 0, arrowX + arrowWidth, height ); FlatUIUtils.paintComponentBackground( g2, 0, 0, width, height, focusWidth, arc ); g2.setClip( oldClip ); } // paint vertical line between value and arrow button g2.setColor( enabled ? borderColor : disabledBorderColor ); float lw = scale( 1f ); float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw; g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2) ) ); paint( g, c ); }