src/main/java/org/jwellman/swing/component/GraphiteButtonUI.java
@Override
    protected void paintText(Graphics gg, AbstractButton button, Rectangle textRect, String text) {

        final Graphics2D g = (Graphics2D)gg;
        
        if (map != null) {
            g.addRenderingHints(map);
        } else {
            g.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); // VALUE_TEXT_ANTIALIAS_ON | VALUE_TEXT_ANTIALIAS_GASP            
        }
        
        final FontMetrics fontMetrics = g.getFontMetrics(button.getFont());
        final int mnemonicIndex = button.getDisplayedMnemonicIndex();

        // paint the shadow text.
        if (!button.getModel().isPressed()) {
            if (!button.getModel().isEnabled() && this.isDrawDisabledState()) {
                // do not draw shadow
            } else {
                g.setColor(TEXT_SHADOW_COLOR);
                if (useDrawString) {
                    g.drawString(
                            text,
                            textRect.x + getTextShiftOffset() + 1,
                            textRect.y + fontMetrics.getAscent() + getTextShiftOffset() + 1);   
                } else {
                    // TODO if windows 7, do not paint the shadow
                    BasicGraphicsUtils.drawStringUnderlineCharAt(
                            g, text, mnemonicIndex,
                            textRect.x + getTextShiftOffset() + 1,
                            textRect.y + fontMetrics.getAscent() + getTextShiftOffset() + 1);                    
                }
            }
        }

        // paint the actual text.
        Color c = TEXT_COLOR;
        if (!button.getModel().isEnabled()) {
            if (this.isDrawDisabledState()) c = TEXT_DISABLED_COLOR;
        } else {
            c = button.getModel().isPressed() ? TEXT_PRESSED_COLOR : TEXT_COLOR;
        }
        g.setColor(c);
        if (useDrawString) {
            g.drawString(
                    text, 
                    textRect.x + getTextShiftOffset(),
                    textRect.y + fontMetrics.getAscent() + getTextShiftOffset());
        } else {
            BasicGraphicsUtils.drawStringUnderlineCharAt(
                    g, text, mnemonicIndex,
                    textRect.x + getTextShiftOffset(),
                    textRect.y + fontMetrics.getAscent() + getTextShiftOffset());
        }
    }
/**
     * We need to override the paintText method so that we can paint
     * the text shadow. the paintText method in BasicButtonUI pulls
     * the color to use from the foreground property -- there is no
     * way to change this during the painting process without causing
     * an infinite sequence of events, so we must implement our own
     * text painting.
     *
     * @param gg
     * @param button
     * @param textRect
     * @param text
     */
We need to override the paintText method so that we can paint
the text shadow. the paintText method in BasicButtonUI pulls
the color to use from the foreground property -- there is no
way to change this during the painting process without causing
an infinite sequence of events, so we must implement our own
text painting.


We need to override the paintText method so that we can paint the text shadow . the paintText method in BasicButtonUI pulls the color to use from the foreground property -- there is no way to change this during the painting process without causing an infinite sequence of events so we must implement our own text painting .
@Override
    protected void paintText(Graphics gg, AbstractButton button, Rectangle textRect, String text) {
        final Graphics2D g = (Graphics2D)gg;
        if (map != null) {
            g.addRenderingHints(map);
        } else {
            g.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); 
        }
        final FontMetrics fontMetrics = g.getFontMetrics(button.getFont());
        final int mnemonicIndex = button.getDisplayedMnemonicIndex();
        if (!button.getModel().isPressed()) {
            if (!button.getModel().isEnabled() && this.isDrawDisabledState()) {
            } else {
                g.setColor(TEXT_SHADOW_COLOR);
                if (useDrawString) {
                    g.drawString(
                            text,
                            textRect.x + getTextShiftOffset() + 1,
                            textRect.y + fontMetrics.getAscent() + getTextShiftOffset() + 1);   
                } else {
                    BasicGraphicsUtils.drawStringUnderlineCharAt(
                            g, text, mnemonicIndex,
                            textRect.x + getTextShiftOffset() + 1,
                            textRect.y + fontMetrics.getAscent() + getTextShiftOffset() + 1);                    
                }
            }
        }
        Color c = TEXT_COLOR;
        if (!button.getModel().isEnabled()) {
            if (this.isDrawDisabledState()) c = TEXT_DISABLED_COLOR;
        } else {
            c = button.getModel().isPressed() ? TEXT_PRESSED_COLOR : TEXT_COLOR;
        }
        g.setColor(c);
        if (useDrawString) {
            g.drawString(
                    text, 
                    textRect.x + getTextShiftOffset(),
                    textRect.y + fontMetrics.getAscent() + getTextShiftOffset());
        } else {
            BasicGraphicsUtils.drawStringUnderlineCharAt(
                    g, text, mnemonicIndex,
                    textRect.x + getTextShiftOffset(),
                    textRect.y + fontMetrics.getAscent() + getTextShiftOffset());
        }
    }
@ Override protected void paintText ( Graphics gg , AbstractButton button , Rectangle textRect , String text ) { final Graphics2D g = ( Graphics2D ) gg ; if ( map != null ) { g . addRenderingHints ( map ) ; } else { g . setRenderingHint ( RenderingHints . KEY_TEXT_ANTIALIASING , RenderingHints . VALUE_TEXT_ANTIALIAS_DEFAULT ) ; } final FontMetrics fontMetrics = g . getFontMetrics ( button . getFont ( ) ) ; final int mnemonicIndex = button . getDisplayedMnemonicIndex ( ) ; if ( ! button . getModel ( ) . isPressed ( ) ) { if ( ! button . getModel ( ) . isEnabled ( ) && this . isDrawDisabledState ( ) ) { } else { g . setColor ( TEXT_SHADOW_COLOR ) ; if ( useDrawString ) { g . drawString ( text , textRect . x + getTextShiftOffset ( ) + 1 , textRect . y + fontMetrics . getAscent ( ) + getTextShiftOffset ( ) + 1 ) ; } else { BasicGraphicsUtils . drawStringUnderlineCharAt ( g , text , mnemonicIndex , textRect . x + getTextShiftOffset ( ) + 1 , textRect . y + fontMetrics . getAscent ( ) + getTextShiftOffset ( ) + 1 ) ; } } } Color c = TEXT_COLOR ; if ( ! button . getModel ( ) . isEnabled ( ) ) { if ( this . isDrawDisabledState ( ) ) c = TEXT_DISABLED_COLOR ; } else { c = button . getModel ( ) . isPressed ( ) ? TEXT_PRESSED_COLOR : TEXT_COLOR ; } g . setColor ( c ) ; if ( useDrawString ) { g . drawString ( text , textRect . x + getTextShiftOffset ( ) , textRect . y + fontMetrics . getAscent ( ) + getTextShiftOffset ( ) ) ; } else { BasicGraphicsUtils . drawStringUnderlineCharAt ( g , text , mnemonicIndex , textRect . x + getTextShiftOffset ( ) , textRect . y + fontMetrics . getAscent ( ) + getTextShiftOffset ( ) ) ; } }
We need to override the paintText method so that we can paint
 the text shadow.
We need to override the paintText method so that we can paint the text shadow .
// VALUE_TEXT_ANTIALIAS_ON | VALUE_TEXT_ANTIALIAS_GASP             // paint the shadow text. // do not draw shadow // TODO if windows 7, do not paint the shadow // paint the actual text.