Java Code Examples for javax.swing.JComponent.isEnabled()

The following are Jave code examples for showing how to use isEnabled() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: rapidminer   File: ScrollBarUI.java   View Source Code Vote up 6 votes
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
	int x = (int) thumbBounds.getX();
	int y = (int) thumbBounds.getY();
	int w = (int) thumbBounds.getWidth();
	int h = (int) thumbBounds.getHeight();

	if (c.isEnabled() && w > 0 && h > 0) {
		if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
			h -= 1;
			y++;
			drawHorizThumb(g, x, y, w, h);
		} else {
			w -= 1;
			x++;
			drawVertThumb(g, x, y, w, h);
		}
	}
}
 
Example 2
Project: rapidminer   File: ComboBoxUI.java   View Source Code Vote up 6 votes
/**
 * Draws the border of the combobox.
 */
private void paintBorder(Graphics g, JComponent c) {
	int w = c.getWidth();
	int h = c.getHeight();
	if (w <= 0 || h <= 0) {
		return;
	}

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	boolean hasFocus = comboBox.isEditable() ? c.isFocusOwner()
			|| ((JComboBox) c).getEditor().getEditorComponent().isFocusOwner() : c.isFocusOwner();
			if (c.isEnabled()) {
				if (hasFocus) {
					g2.setColor(Colors.COMBOBOX_BORDER_FOCUS);
				} else {
					g2.setColor(Colors.COMBOBOX_BORDER);
				}
			} else {
				g2.setColor(Colors.COMBOBOX_BORDER_DISABLED);
			}

			g2.drawRoundRect(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
 
Example 3
Project: JavaGraph   File: ResourceDisplay.java   View Source Code Vote up 5 votes
/** Adjust the info panel by retrieving upper and lower info subpanels from the selected tab. */
protected void buildInfoPanel() {
    JComponent upperInfoPanel = null;
    JComponent lowerInfoPanel = null;
    ResourceTab tab = getSelectedTab();
    if (tab != null) {
        upperInfoPanel = tab.getUpperInfoPanel();
        lowerInfoPanel = tab.getLowerInfoPanel();
    }
    JPanel infoPanel = (JPanel) getInfoPanel();
    String key;
    if (lowerInfoPanel == null || !lowerInfoPanel.isEnabled()) {
        // if we switch from split to single, freeze the divider location
        if (upperInfoPanel != null && upperInfoPanel.getParent() == getSplitInfoPanel()) {
            this.frozenDividerPos = getSplitInfoPanel().getDividerLocation();
        }
        getSingleInfoPanel().removeAll();
        if (upperInfoPanel != null) {
            getSingleInfoPanel().add(upperInfoPanel, BorderLayout.CENTER);
            getSingleInfoPanel().validate();
            getSingleInfoPanel().repaint();
        }
        key = this.SINGLE_INFO_KEY;
    } else {
        JSplitPane splitInfoPanel = getSplitInfoPanel();
        int dividerPos = this.frozenDividerPos;
        this.frozenDividerPos = 0;
        if (dividerPos == 0) {
            dividerPos = splitInfoPanel.getDividerLocation();
        }
        splitInfoPanel.setTopComponent(upperInfoPanel);
        splitInfoPanel.setBottomComponent(lowerInfoPanel);
        splitInfoPanel.setDividerLocation(dividerPos);
        key = this.SPLIT_INFO_KEY;
    }
    ((CardLayout) infoPanel.getLayout()).show(infoPanel, key);
}
 
Example 4
Project: Equella   File: FlatterCheckBoxUI.java   View Source Code Vote up 5 votes
@Override
public synchronized void mousePressed(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	if( c.isEnabled() )
	{
		c.setForeground(mTextPressed);
		c.setBackground(mBackgroundPressed);
		c.repaint();
	}
}
 
Example 5
Project: Equella   File: FlatterCheckBoxUI.java   View Source Code Vote up 5 votes
@Override
public synchronized void mouseEntered(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	if( c.isEnabled() )
	{
		c.setForeground(mTextActive);
		c.setBackground(mBackgroundActive);
		c.repaint();
	}
}
 
Example 6
Project: openjdk-jdk10   File: AquaScrollRegionBorder.java   View Source Code Vote up 5 votes
protected State getState(final JComponent c) {
    if (!AquaFocusHandler.isActive(c)) return State.INACTIVE;
    if (!c.isEnabled()) return State.DISABLED;
    return State.ACTIVE;
}
 
Example 7
Project: incubator-netbeans   File: IntroduceMethodPanel.java   View Source Code Vote up 4 votes
private boolean isAvailable(JComponent c) {
    return c.isVisible() && c.isEnabled();
}
 
Example 8
Project: rapidminer   File: ComboBoxUI.java   View Source Code Vote up 4 votes
/**
 * Draws the combobox itself.
 */
private void paintBox(Graphics g, JComponent c) {
	int w = c.getWidth();
	int h = c.getHeight() - 1;
	if (w <= 0 || h <= 0) {
		return;
	}

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	if (c.isEnabled()) {
		if (Boolean.parseBoolean(String.valueOf(c.getClientProperty(RapidLookTools.PROPERTY_INPUT_BACKGROUND_DARK)))) {
			g2.setColor(Colors.COMBOBOX_BACKGROUND_DARK);
		} else {
			g2.setColor(Colors.COMBOBOX_BACKGROUND);
		}
	} else {
		g2.setColor(Colors.COMBOBOX_BACKGROUND_DISABLED);
	}

	g2.fillRoundRect(0, 0, w - 1, h, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	// arrow
	int ny = c.getSize().height / 2 - 3;
	int nx = c.getWidth() - 15;

	if (isDown && c.isEnabled()) {
		nx++;
		ny++;
	}
	g2.translate(nx, ny);

	if (c.isEnabled()) {
		g2.setColor(Colors.COMBOBOX_ARROW);
	} else {
		g2.setColor(Colors.COMBOBOX_ARROW_DISABLED);
	}

	w = 14;
	Polygon arrow = new Polygon(new int[] { 0, 4, 8 }, new int[] { 0, 6, 0 }, 3);
	g2.fillPolygon(arrow);

	g2.translate(-nx, -ny);
}
 
Example 9
Project: OpenJSharp   File: MetalScrollBarUI.java   View Source Code Vote up 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
Project: OpenJSharp   File: AquaScrollRegionBorder.java   View Source Code Vote up 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
Project: jdk8u-jdk   File: MetalScrollBarUI.java   View Source Code Vote up 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
Project: jdk8u-jdk   File: AquaScrollRegionBorder.java   View Source Code Vote up 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 13
Project: openjdk-jdk10   File: MetalScrollBarUI.java   View Source Code Vote up 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 );
}