Java Code Examples for java.awt.Graphics#getColor()

The following examples show how to use java.awt.Graphics#getColor() . 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: BasicGraphicsUtils.java    From JDKSourceCode1.8 with MIT License 8 votes vote down vote up
public static void drawGroove(Graphics g, int x, int y, int w, int h,
                              Color shadow, Color highlight)
{
    Color oldColor = g.getColor();  // Make no net change to g
    g.translate(x, y);

    g.setColor(shadow);
    g.drawRect(0, 0, w-2, h-2);

    g.setColor(highlight);
    g.drawLine(1, h-3, 1, 1);
    g.drawLine(1, 1, w-3, 1);

    g.drawLine(0, h-1, w-1, h-1);
    g.drawLine(w-1, h-1, w-1, 0);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
Example 2
Source File: MotifIconFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void drawCheckBezelOut(Graphics g, int x, int y, int csize){
    Color controlShadow = UIManager.getColor("controlShadow");

    int w = csize;
    int h = csize;
    Color oldColor = g.getColor();

    g.translate(x,y);
    g.setColor(highlight);    // inner 3D border
    g.drawLine(0, 0, 0, h-1);
    g.drawLine(1, 0, w-1, 0);

    g.setColor(shadow);         // black drop shadow  __|
    g.drawLine(1, h-1, w-1, h-1);
    g.drawLine(w-1, h-1, w-1, 1);
    g.translate(-x,-y);
    g.setColor(oldColor);
}
 
Example 3
Source File: MotifIconFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void drawCheckBezelOut(Graphics g, int x, int y, int csize){
    Color controlShadow = UIManager.getColor("controlShadow");

    int w = csize;
    int h = csize;
    Color oldColor = g.getColor();

    g.translate(x,y);
    g.setColor(highlight);    // inner 3D border
    g.drawLine(0, 0, 0, h-1);
    g.drawLine(1, 0, w-1, 0);

    g.setColor(shadow);         // black drop shadow  __|
    g.drawLine(1, h-1, w-1, h-1);
    g.drawLine(w-1, h-1, w-1, 1);
    g.translate(-x,-y);
    g.setColor(oldColor);
}
 
Example 4
Source File: MiniMap.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a red crosshair for artillery autohit hexes (predesignated only).
 */
private void drawAutoHit(Graphics g, Coords hex) {
    int baseX = (hex.getX() * (hexSide[zoom] + hexSideBySin30[zoom])) + leftMargin
                + hexSide[zoom];
    int baseY = (((2 * hex.getY()) + 1 + (hex.getX() % 2)) * hexSideByCos30[zoom])
                + topMargin;
    Color alt = g.getColor();
    g.setColor(Color.RED);
    g.drawOval(baseX - (unitSize - 1), baseY - (unitSize - 1),
               (2 * unitSize) - 2, (2 * unitSize) - 2);
    g.drawLine(baseX - unitSize - 1, baseY, (baseX - unitSize) + 3, baseY);
    g.drawLine(baseX + unitSize + 1, baseY, (baseX + unitSize) - 3, baseY);
    g.drawLine(baseX, baseY - unitSize - 1, baseX, (baseY - unitSize) + 3);
    g.drawLine(baseX, baseY + unitSize + 1, baseX, (baseY + unitSize) - 3);
    g.setColor(alt);
}
 
Example 5
Source File: BasicGraphicsUtils.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public static void drawEtchedRect(Graphics g, int x, int y, int w, int h,
                                  Color shadow, Color darkShadow,
                                  Color highlight, Color lightHighlight)
{
    Color oldColor = g.getColor();  // Make no net change to g
    g.translate(x, y);

    g.setColor(shadow);
    g.drawLine(0, 0, w-1, 0);      // outer border, top
    g.drawLine(0, 1, 0, h-2);      // outer border, left

    g.setColor(darkShadow);
    g.drawLine(1, 1, w-3, 1);      // inner border, top
    g.drawLine(1, 2, 1, h-3);      // inner border, left

    g.setColor(lightHighlight);
    g.drawLine(w-1, 0, w-1, h-1);  // outer border, bottom
    g.drawLine(0, h-1, w-1, h-1);  // outer border, right

    g.setColor(highlight);
    g.drawLine(w-2, 1, w-2, h-3);  // inner border, right
    g.drawLine(1, h-2, w-2, h-2);  // inner border, bottom

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
Example 6
Source File: JTitledPanel.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) {
    if (!c.isEnabled()) {
        return;
    }

    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getHighlightInnerColor(c));
    g.drawLine(0, 0, 0, h - 1);
    g.drawLine(1, 0, w - 1, 0);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 0, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
Example 7
Source File: DisplayAreaSupport.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected void paintLoweredBevel(Component c, Graphics g, int x, int y, int width, int height) {
    if (!c.isEnabled()) {
        return;
    }

    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, 0, 0, h - 1);
    g.drawLine(1, 0, w - 1, 0);

    g.setColor(getHighlightInnerColor(c));
    g.drawLine(1, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 1, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
Example 8
Source File: XComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draw a 3D oval.
 */
public void draw3DOval(Graphics g, Color colors[],
                       int x, int y, int w, int h, boolean raised)
    {
    Color c = g.getColor();
    g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 9
Source File: BasicBorders.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    g.translate(x, y);
    g.setColor(shadow);
    g.drawLine(0, height-2, width, height-2);
    g.setColor(highlight);
    g.drawLine(0, height-1, width, height-1);
    g.translate(-x,-y);
    g.setColor(oldColor);
}
 
Example 10
Source File: BasicBorders.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    g.translate(x, y);
    g.setColor(shadow);
    g.drawLine(0, height-2, width, height-2);
    g.setColor(highlight);
    g.drawLine(0, height-1, width, height-1);
    g.translate(-x,-y);
    g.setColor(oldColor);
}
 
Example 11
Source File: GTKGraphicsUtils.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void paintText(SynthContext context, Graphics g, String text,
                      int x, int y, int mnemonicIndex) {
    if (text == null || text.length() <= 0) {
        // We don't need to paint empty strings
        return;
    }

    if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) {
        // Metacity handles painting of text on internal frame title,
        // ignore this.
        return;
    }
    int componentState = context.getComponentState();
    if ((componentState & SynthConstants.DISABLED) ==
                          SynthConstants.DISABLED){
        Color orgColor = g.getColor();
        g.setColor(context.getStyle().getColor(context,
                                               GTKColorType.WHITE));
        x += 1;
        y += 1;
        super.paintText(context, g, text, x, y, mnemonicIndex);

        g.setColor(orgColor);
        x -= 1;
        y -= 1;
        super.paintText(context, g, text, x, y, mnemonicIndex);
    }
    else {
        String themeName = GTKLookAndFeel.getGtkThemeName();
        if (themeName != null && themeName.startsWith("blueprint") &&
            shouldShadowText(context.getRegion(), componentState)) {

            g.setColor(Color.BLACK);
            super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
            g.setColor(Color.WHITE);
        }

        super.paintText(context, g, text, x, y, mnemonicIndex);
    }
}
 
Example 12
Source File: BevelBorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
                                int width, int height)  {
    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getHighlightOuterColor(c));
    g.drawLine(0, 0, 0, h-2);
    g.drawLine(1, 0, w-2, 0);

    g.setColor(getHighlightInnerColor(c));
    g.drawLine(1, 1, 1, h-3);
    g.drawLine(2, 1, w-3, 1);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, h-1, w-1, h-1);
    g.drawLine(w-1, 0, w-1, h-2);

    g.setColor(getShadowInnerColor(c));
    g.drawLine(1, h-2, w-2, h-2);
    g.drawLine(w-2, 1, w-2, h-3);

    g.translate(-x, -y);
    g.setColor(oldColor);

}
 
Example 13
Source File: MatteBorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints the matte border.
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Insets insets = getBorderInsets(c);
    Color oldColor = g.getColor();
    g.translate(x, y);

    // If the tileIcon failed loading, paint as gray.
    if (tileIcon != null) {
        color = (tileIcon.getIconWidth() == -1) ? Color.gray : null;
    }

    if (color != null) {
        g.setColor(color);
        g.fillRect(0, 0, width - insets.right, insets.top);
        g.fillRect(0, insets.top, insets.left, height - insets.top);
        g.fillRect(insets.left, height - insets.bottom, width - insets.left, insets.bottom);
        g.fillRect(width - insets.right, 0, insets.right, height - insets.bottom);

    } else if (tileIcon != null) {
        int tileW = tileIcon.getIconWidth();
        int tileH = tileIcon.getIconHeight();
        paintEdge(c, g, 0, 0, width - insets.right, insets.top, tileW, tileH);
        paintEdge(c, g, 0, insets.top, insets.left, height - insets.top, tileW, tileH);
        paintEdge(c, g, insets.left, height - insets.bottom, width - insets.left, insets.bottom, tileW, tileH);
        paintEdge(c, g, width - insets.right, 0, insets.right, height - insets.bottom, tileW, tileH);
    }
    g.translate(-x, -y);
    g.setColor(oldColor);

}
 
Example 14
Source File: BevelBorder.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Paints a raised bevel for the specified component with the specified
 * position and size.
 *
 * @param c the component for which the raised bevel is being painted
 * @param g the paint graphics
 * @param x the x position of the raised bevel
 * @param y the y position of the raised bevel
 * @param width the width of the raised bevel
 * @param height the height of the raised bevel
 */
protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
                                int width, int height)  {
    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getHighlightOuterColor(c));
    g.drawLine(0, 0, 0, h-2);
    g.drawLine(1, 0, w-2, 0);

    g.setColor(getHighlightInnerColor(c));
    g.drawLine(1, 1, 1, h-3);
    g.drawLine(2, 1, w-3, 1);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, h-1, w-1, h-1);
    g.drawLine(w-1, 0, w-1, h-2);

    g.setColor(getShadowInnerColor(c));
    g.drawLine(1, h-2, w-2, h-2);
    g.drawLine(w-2, 1, w-2, h-3);

    g.translate(-x, -y);
    g.setColor(oldColor);

}
 
Example 15
Source File: MatteBorder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints the matte border.
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Insets insets = getBorderInsets(c);
    Color oldColor = g.getColor();
    g.translate(x, y);

    // If the tileIcon failed loading, paint as gray.
    if (tileIcon != null) {
        color = (tileIcon.getIconWidth() == -1) ? Color.gray : null;
    }

    if (color != null) {
        g.setColor(color);
        g.fillRect(0, 0, width - insets.right, insets.top);
        g.fillRect(0, insets.top, insets.left, height - insets.top);
        g.fillRect(insets.left, height - insets.bottom, width - insets.left, insets.bottom);
        g.fillRect(width - insets.right, 0, insets.right, height - insets.bottom);

    } else if (tileIcon != null) {
        int tileW = tileIcon.getIconWidth();
        int tileH = tileIcon.getIconHeight();
        paintEdge(c, g, 0, 0, width - insets.right, insets.top, tileW, tileH);
        paintEdge(c, g, 0, insets.top, insets.left, height - insets.top, tileW, tileH);
        paintEdge(c, g, insets.left, height - insets.bottom, width - insets.left, insets.bottom, tileW, tileH);
        paintEdge(c, g, width - insets.right, 0, insets.right, height - insets.bottom, tileW, tileH);
    }
    g.translate(-x, -y);
    g.setColor(oldColor);

}
 
Example 16
Source File: MotifIconFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y) {
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    // These variables are kind of pointless as the following code
    // assumes the icon will be 10 x 10 regardless of their value.
    int w = getIconWidth();
    int h = getIconHeight();

    Color oldColor = g.getColor();

    if (model.isSelected()){
        if( MotifGraphicsUtils.isLeftToRight(c) ){
            g.setColor(shadow);
            g.fillRect(x+1,y+1,2,h);
            g.drawLine(x+4,y+2,x+4,y+2);
            g.drawLine(x+6,y+3,x+6,y+3);
            g.drawLine(x+8,y+4,x+8,y+5);
            g.setColor(focus);
            g.fillRect(x+2,y+2,2,h-2);
            g.fillRect(x+4,y+3,2,h-4);
            g.fillRect(x+6,y+4,2,h-6);
            g.setColor(highlight);
            g.drawLine(x+2,y+h,x+2,y+h);
            g.drawLine(x+4,y+h-1,x+4,y+h-1);
            g.drawLine(x+6,y+h-2,x+6,y+h-2);
            g.drawLine(x+8,y+h-4,x+8,y+h-3);
        } else {
            g.setColor(highlight);
            g.fillRect(x+7,y+1,2,10);
            g.drawLine(x+5,y+9,x+5,y+9);
            g.drawLine(x+3,y+8,x+3,y+8);
            g.drawLine(x+1,y+6,x+1,y+7);
            g.setColor(focus);
            g.fillRect(x+6,y+2,2,8);
            g.fillRect(x+4,y+3,2,6);
            g.fillRect(x+2,y+4,2,4);
            g.setColor(shadow);
            g.drawLine(x+1,y+4,x+1,y+5);
            g.drawLine(x+3,y+3,x+3,y+3);
            g.drawLine(x+5,y+2,x+5,y+2);
            g.drawLine(x+7,y+1,x+7,y+1);
        }
    } else {
        if( MotifGraphicsUtils.isLeftToRight(c) ){
            g.setColor(highlight);
            g.drawLine(x+1,y+1,x+1,y+h);
            g.drawLine(x+2,y+1,x+2,y+h-2);
            g.fillRect(x+3,y+2,2,2);
            g.fillRect(x+5,y+3,2,2);
            g.fillRect(x+7,y+4,2,2);
            g.setColor(shadow);
            g.drawLine(x+2,y+h-1,x+2,y+h);
            g.fillRect(x+3,y+h-2,2,2);
            g.fillRect(x+5,y+h-3,2,2);
            g.fillRect(x+7,y+h-4,2,2);
            g.setColor(oldColor);
        } else {
            g.setColor(highlight);
            g.fillRect(x+1,y+4,2,2);
            g.fillRect(x+3,y+3,2,2);
            g.fillRect(x+5,y+2,2,2);
            g.drawLine(x+7,y+1,x+7,y+2);
            g.setColor(shadow);
            g.fillRect(x+1,y+h-4,2,2);
            g.fillRect(x+3,y+h-3,2,2);
            g.fillRect(x+5,y+h-2,2,2);
            g.drawLine(x+7,y+3,x+7,y+h);
            g.drawLine(x+8,y+1,x+8,y+h);
            g.setColor(oldColor);
        }
    }

}
 
Example 17
Source File: BookmarkKeyChooser.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void addCells(JPanel cellPanel, int cellCount, char... startToLastPairs) {
    Color foreColor = UIManager.getColor("Table.foreground");
    Color backColor = UIManager.getColor("Table.background");
    Color selForeColor = UIManager.getColor("Table.selectionForeground");
    Color selBackColor = UIManager.getColor("Table.selectionBackground");
    Border cellBorder = new LineBorder(Color.BLACK, 1, true);
    int cellId = 0;
    for (int i = 0; i < startToLastPairs.length;) {
        char start = startToLastPairs[i++];
        char last = startToLastPairs[i++];
        while (start <= last) {
            JLabel cell = new JLabel(" " + start + " ", SwingConstants.CENTER) {
                @Override
                public void paintComponent(Graphics g) {
                    Rectangle clip = g.getClipBounds();
                    Color origColor = g.getColor();
                    g.setColor(getBackground());
                    g.fillRect(clip.x, clip.y, clip.width, clip.height);
                    g.setColor(origColor);
                    super.paintComponent(g);
                }
            };
            final BookmarkInfo bookmark = key2bookmark.get(start);
            if (bookmark != null) {
                cell.setForeground(selForeColor);
                cell.setBackground(selBackColor);
                cell.setToolTipText(bookmark.getDescription(true, false, false));
                cell.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        if (e.getClickCount() == 1) {
                            result = bookmark;
                            dispose();
                        }
                    }
                });
            } else {
                cell.setForeground(foreColor);
                cell.setBackground(backColor);
                cell.setToolTipText(NbBundle.getMessage(BookmarkKeyChooser.class,
                        "CTL_keyChooserUnoccupiedBookmarkKey")); // NOI18N
            }
            cell.setBorder(cellBorder);
            cellPanel.add(cell);
            cellId++;
            start++;
        }
    }
    // Fill in remaining cells (otherwise only would be 9x4)
    while (cellId < cellCount) {
        cellPanel.add(new JPanel());
        cellId++;
    }
}
 
Example 18
Source File: GTKGraphicsUtils.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Paints text at the specified location. This will not attempt to
 * render the text as html nor will it offset by the insets of the
 * component.
 *
 * @param ss SynthContext
 * @param g Graphics used to render string in.
 * @param text Text to render
 * @param bounds Bounds of the text to be drawn.
 * @param mnemonicIndex Index to draw string at.
 */
public void paintText(SynthContext context, Graphics g, String text,
                      Rectangle bounds, int mnemonicIndex) {
    if (text == null || text.length() <= 0) {
        // We don't need to paint empty strings
        return;
    }

    Region id = context.getRegion();
    if ((id == Region.RADIO_BUTTON ||
         id == Region.CHECK_BOX ||
         id == Region.TABBED_PANE_TAB) &&
        (context.getComponentState() & SynthConstants.FOCUSED) != 0)
    {
        JComponent source = context.getComponent();
        if (!(source instanceof AbstractButton) ||
            ((AbstractButton)source).isFocusPainted()) {

            // The "bounds" parameter encompasses only the actual text;
            // when drawing the focus, we need to expand that bounding
            // box by "focus-line-width" plus "focus-padding".  Note that
            // the layout process for these components will have already
            // taken these values into account, so there should always
            // be enough space allocated for drawing the focus indicator.
            int synthState = context.getComponentState();
            GTKStyle style = (GTKStyle)context.getStyle();
            int focusSize =
                style.getClassSpecificIntValue(context,
                                               "focus-line-width", 1);
            int focusPad =
                style.getClassSpecificIntValue(context,
                                               "focus-padding", 1);
            int totalFocus = focusSize + focusPad;
            int x = bounds.x - totalFocus;
            int y = bounds.y - totalFocus;
            int w = bounds.width  + (2 * totalFocus);
            int h = bounds.height + (2 * totalFocus);

            Color color = g.getColor();
            GTKPainter.INSTANCE.paintFocus(context, g, id,
                                           synthState, "checkbutton",
                                           x, y, w, h);
            g.setColor(color);
        }
    }
    super.paintText(context, g, text, bounds, mnemonicIndex);
}
 
Example 19
Source File: BasicGraphicsUtils.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void drawBezel(Graphics g, int x, int y, int w, int h,
                             boolean isPressed, boolean isDefault,
                             Color shadow, Color darkShadow,
                             Color highlight, Color lightHighlight)
{
    Color oldColor = g.getColor();  // Make no net change to g
    g.translate(x, y);

    if (isPressed && isDefault) {
        g.setColor(darkShadow);
        g.drawRect(0, 0, w - 1, h - 1);
        g.setColor(shadow);
        g.drawRect(1, 1, w - 3, h - 3);
    } else if (isPressed) {
        drawLoweredBezel(g, x, y, w, h,
                         shadow, darkShadow, highlight, lightHighlight);
    } else if (isDefault) {
        g.setColor(darkShadow);
        g.drawRect(0, 0, w-1, h-1);

        g.setColor(lightHighlight);
        g.drawLine(1, 1, 1, h-3);
        g.drawLine(2, 1, w-3, 1);

        g.setColor(highlight);
        g.drawLine(2, 2, 2, h-4);
        g.drawLine(3, 2, w-4, 2);

        g.setColor(shadow);
        g.drawLine(2, h-3, w-3, h-3);
        g.drawLine(w-3, 2, w-3, h-4);

        g.setColor(darkShadow);
        g.drawLine(1, h-2, w-2, h-2);
        g.drawLine(w-2, h-2, w-2, 1);
    } else {
        g.setColor(lightHighlight);
        g.drawLine(0, 0, 0, h-1);
        g.drawLine(1, 0, w-2, 0);

        g.setColor(highlight);
        g.drawLine(1, 1, 1, h-3);
        g.drawLine(2, 1, w-3, 1);

        g.setColor(shadow);
        g.drawLine(1, h-2, w-2, h-2);
        g.drawLine(w-2, 1, w-2, h-3);

        g.setColor(darkShadow);
        g.drawLine(0, h-1, w-1, h-1);
        g.drawLine(w-1, h-1, w-1, 0);
    }
    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
Example 20
Source File: MotifBorders.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if (!(c instanceof JPopupMenu)) {
        return;
    }

    Font origFont = g.getFont();
    Color origColor = g.getColor();
    JPopupMenu popup = (JPopupMenu)c;

    String title = popup.getLabel();
    if (title == null) {
        return;
    }

    g.setFont(font);

    FontMetrics fm = SwingUtilities2.getFontMetrics(popup, g, font);
    int         fontHeight = fm.getHeight();
    int         descent = fm.getDescent();
    int         ascent = fm.getAscent();
    Point       textLoc = new Point();
    int         stringWidth = SwingUtilities2.stringWidth(popup, fm,
                                                          title);

    textLoc.y = y + ascent + TEXT_SPACING;
    textLoc.x = x + ((width - stringWidth) / 2);

    g.setColor(background);
    g.fillRect(textLoc.x - TEXT_SPACING, textLoc.y - (fontHeight-descent),
               stringWidth + (2 * TEXT_SPACING), fontHeight - descent);
    g.setColor(foreground);
    SwingUtilities2.drawString(popup, g, title, textLoc.x, textLoc.y);

    MotifGraphicsUtils.drawGroove(g, x, textLoc.y + TEXT_SPACING,
                                  width, GROOVE_HEIGHT,
                                  shadowColor, highlightColor);

    g.setFont(origFont);
    g.setColor(origColor);
}