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

The following are Jave code examples for showing how to use getBackground() 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: batmapper   File: ExitLabelRenderer.java   View Source Code Vote up 6 votes
public <E> Component getEdgeLabelRendererComponent( JComponent vv, Object value, Font font, boolean isSelected, E edge ) {

        super.setForeground( vv.getForeground() );
        if (edge instanceof Exit) {
            Exit exit = (Exit) edge;
            if (exit.isCurrentExit()) {
                setForeground( pickedEdgeLabelColor );
            } else {
                setForeground( unPickedEdgeLabelColor );
            }
        }

        super.setBackground( vv.getBackground() );

        if (font != null) {
            setFont( font );
        } else {
            setFont( vv.getFont() );
        }
        setIcon( null );
        setBorder( noFocusBorder );
        setValue( value );
        return this;
    }
 
Example 2
Project: incubator-netbeans   File: ViewUtil.java   View Source Code Vote up 5 votes
/**
 * Change background of given component to light gray on Mac look and feel
 * when the component is in a tabbed container and its background hasn't been
 * already changed (is instance of UIResource).
 * @param c
 */
static void adjustBackground( JComponent c ) {
    if( !isAquaLaF || useDefaultBackground )
        return;

    if( !isInTabbedContainer(c) )
        return;

    Color currentBackground = c.getBackground();
    if( currentBackground instanceof UIResource ) {
        c.setBackground(UIManager.getColor("NbExplorerView.background"));
    }
}
 
Example 3
Project: incubator-netbeans   File: NimbusViewTabDisplayerUI.java   View Source Code Vote up 5 votes
/**
 * adds painting of overall border
 */
@Override
public void paint(Graphics g, JComponent c) {

    ColorUtil.setupAntialiasing(g);

    Color col = c.getBackground();
    if (col != null) {
        g.setColor (col);
        g.fillRect (0, 0, c.getWidth(), c.getHeight());
    }
    paintOverallBorder(g, c);
    super.paint(g, c);
}
 
Example 4
Project: incubator-netbeans   File: WinClassicViewTabDisplayerUI.java   View Source Code Vote up 5 votes
/**
 * adds painting of overall border
 */
@Override
public void paint(Graphics g, JComponent c) {

    ColorUtil.setupAntialiasing(g);

    Color col = c.getBackground();
    if (col != null) {
        g.setColor (col);
        g.fillRect (0, 0, c.getWidth(), c.getHeight());
    }
    paintOverallBorder(g, c);
    super.paint(g, c);
}
 
Example 5
Project: incubator-netbeans   File: GtkViewTabDisplayerUI.java   View Source Code Vote up 5 votes
/**
 * adds painting of overall border
 */
public void paint(Graphics g, JComponent c) {

    ColorUtil.setupAntialiasing(g);

    Color col = c.getBackground();
    if (col != null) {
        g.setColor (col);
        g.fillRect (0, 0, c.getWidth(), c.getHeight());
    }
    paintOverallBorder(g, c);
    super.paint(g, c);
}
 
Example 6
Project: incubator-netbeans   File: Coloring.java   View Source Code Vote up 4 votes
/** Apply this coloring to component colors/font.
* The underline and strikeThrough line colors have no effect here.
*/
public void apply(JComponent c) {
    // Possibly change font
    if (font != null) {
        if (fontMode == FONT_MODE_DEFAULT) {
            c.setFont(font);

        } else { // non-default font-mode
            Font origFont = c.getFont();
            if (origFont != null) {
                synchronized (cacheLock) {
                    Font f = (Font)fontAndForeColorCache.get(origFont);
                    if (f == null) {
                        f = modifyFont(origFont);
                        fontAndForeColorCache.put(origFont, f);
                    }
                    c.setFont(f);
                }
            }
        }
    }

    // Possibly change fore-color
    if (foreColor != null) {
        if (!hasAlpha(foreColor)) {
            c.setForeground(foreColor);

        } else { // non-default fore color-mode
            Color origForeColor = c.getForeground();
            if (origForeColor != null) {
                synchronized (cacheLock) {
                    Color fc = (Color)fontAndForeColorCache.get(origForeColor);
                    if (fc == null) {
                        fc = modifyForeColor(origForeColor);
                        fontAndForeColorCache.put(origForeColor, fc);
                    }
                    c.setForeground(fc);
                }
            }
        }
    }

    // Possibly change back-color
    if (backColor != null) {
        if (!hasAlpha(backColor)) {
            c.setBackground(backColor);

        } else { // non-default back color-mode
            Color origBackColor = c.getBackground();
            if (origBackColor != null) {
                synchronized (cacheLock) {
                    Color bc = (Color)backColorCache.get(origBackColor);
                    if (bc == null) {
                        bc = modifyBackColor(origBackColor);
                        backColorCache.put(origBackColor, bc);
                    }
                    c.setBackground(bc);
                }
            }
        }
    }
}
 
Example 7
Project: OpenJSharp   File: LoweredBorder.java   View Source Code Vote up 4 votes
@Override
protected Object[] getExtendedCacheKeys(JComponent c) {
    return (c != null)
            ? new Object[] { c.getBackground() }
            : null;
}
 
Example 8
Project: jdk8u-jdk   File: LoweredBorder.java   View Source Code Vote up 4 votes
@Override
protected Object[] getExtendedCacheKeys(JComponent c) {
    return (c != null)
            ? new Object[] { c.getBackground() }
            : null;
}
 
Example 9
Project: openjdk-jdk10   File: LoweredBorder.java   View Source Code Vote up 4 votes
@Override
protected Object[] getExtendedCacheKeys(JComponent c) {
    return (c != null)
            ? new Object[] { c.getBackground() }
            : null;
}