javax.swing.JComponent#isEnabled ( )源码实例Demo

下面列出了javax.swing.JComponent#isEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: seaglass   文件: SeaGlassMenuUI.java
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;
}
 
源代码2 项目: FlatLaf   文件: FlatToggleButtonUI.java
@Override
protected Color getForeground( JComponent c ) {
	if( c.isEnabled() && ((AbstractButton)c).isSelected() && !isToolBarButton( c ) )
		return selectedForeground;

	return super.getForeground( c );
}
 
源代码3 项目: seaglass   文件: SeaGlassMenuItemUI.java
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;
}
 
源代码4 项目: seaglass   文件: SeaGlassTextFieldUI.java
/**
 * 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);
}
 
源代码5 项目: seaglass   文件: SeaGlassTabbedPaneUI.java
/**
 * 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;
}
 
@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;
}
 
源代码7 项目: PolyGlot   文件: PToolTipUI.java
/**
 * 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");
    }
}
 
源代码8 项目: jdk8u-jdk   文件: MetalScrollBarUI.java
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 );
}
 
源代码9 项目: FlatLaf   文件: FlatDatePickerUI.java
@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 );
}
 
源代码10 项目: jdk8u-jdk   文件: MetalScrollBarUI.java
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 );
}
 
源代码11 项目: jdk8u-jdk   文件: AquaScrollRegionBorder.java
protected State getState(final JComponent c) {
    if (!AquaFocusHandler.isActive(c)) return State.INACTIVE;
    if (!c.isEnabled()) return State.DISABLED;
    return State.ACTIVE;
}
 
源代码12 项目: dragonwell8_jdk   文件: AquaScrollRegionBorder.java
protected State getState(final JComponent c) {
    if (!AquaFocusHandler.isActive(c)) return State.INACTIVE;
    if (!c.isEnabled()) return State.DISABLED;
    return State.ACTIVE;
}
 
源代码13 项目: TencentKona-8   文件: MetalScrollBarUI.java
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 );
}
 
源代码14 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * 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;
}
 
源代码15 项目: JDKSourceCode1.8   文件: MetalScrollBarUI.java
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 );
}
 
源代码16 项目: openjdk-jdk8u   文件: MetalScrollBarUI.java
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 );
}
 
源代码17 项目: netbeans   文件: IntroduceMethodPanel.java
private boolean isAvailable(JComponent c) {
    return c.isVisible() && c.isEnabled();
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: MetalScrollBarUI.java
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 );
}
 
源代码19 项目: openjdk-8-source   文件: AquaScrollRegionBorder.java
protected State getState(final JComponent c) {
    if (!AquaFocusHandler.isActive(c)) return State.INACTIVE;
    if (!c.isEnabled()) return State.DISABLED;
    return State.ACTIVE;
}
 
源代码20 项目: Bytecoder   文件: MetalScrollBarUI.java
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 );
}