Patch to fix EmphasizedLabel in OpenJDK 7

7 views
Skip to first unread message

Steve McLeod

unread,
Apr 23, 2012, 5:31:08 AM4/23/12
to mac-widget...@googlegroups.com
The rendering in EmphasizedLabelUI doesn't work properly in OpenJDK 7 on Mac. It uses the wrong font and doesn't anti-alias.

I spent too much time this weekend on creating a work-around, before finally coming up with a simple solution. 

The patch attached will fix the problem.

Regards,

Steve
---------------------------------------------------
Steve McLeod
Founder, Poker Copilot
http://www.pokercopilot.com


EmpahsizedLabelUI_OpenJDK7_Patch.patch

Steve McLeod

unread,
Apr 23, 2012, 6:10:28 AM4/23/12
to mac-widget...@googlegroups.com
Another approach is to manually turn on anti aliasing when drawing the emphasized label:

    protected void paintEnabledText(JLabel label, Graphics g, String s, int textX, int textY) {
        final Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        ....
   }

and

    protected void paintDisabledText(JLabel label, Graphics g, String s, int textX, int textY) {
        final Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        ....
   }

I tried understanding the Oracle code to find the root of the problem, but alas, understanding the core Swing rendering code is not an easy undertaking.

Ken Orr

unread,
Apr 23, 2012, 10:54:32 AM4/23/12
to mac-widget...@googlegroups.com
Steve,

I've added you as a committer to the project. Feel free to integrate the patch.

-Ken

--
You received this message because you are subscribed to the Google Groups "Mac Widgets for Java" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mac-widgets-for-java/-/19AKuS0sqqAJ.

To post to this group, send email to mac-widget...@googlegroups.com.
To unsubscribe from this group, send email to mac-widgets-for-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mac-widgets-for-java?hl=en.

Reply all
Reply to author
Forward
0 new messages