Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text rendering artifacts



Hey Mike,

I had originally thought that might be the issue, but I don't think that wholly explains the problem. I updated my test case to create an intermediary JPanel with opacity set to true (see sample code below). Doing that makes the artifacts show up much less frequently, but as you can see in the screen shots below (re-shot with new test case), it is still reproducible. Any thoughts?

PNG image

PNG image


public class TextAntialiasingTest {

public static void main(String[] args) {
JLabel button = new JLabel("A Button With Some Text", SwingConstants.CENTER);
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(true);
panel.add(button);


        JFrame frame = new JFrame();
        frame.add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(200,100);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

}

-Ken

On Sep 4, 2008, at 11:02 AM, Mike Swingler wrote:

On Sep 4, 2008, at 5:36 AM, Ken Orr wrote:

Does anyone know why resizing a window can cause weird text drawing
artifacts (see below)? Running with -
Dapple.awt.graphics.UseQuartz=true doesn't seem to help much.

Good text:
<good_text.png>
Bad text (after tiny resize):
<bad_text.png>

Here's some sample code to reproduce the problem:

public class TextAntialiasingTest {

  public static void main(String[] args) {
      JLabel button = new JLabel("A Button With Some Text",
SwingConstants.CENTER);

      JFrame frame = new JFrame();
      frame.add(button);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(200,100);
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
  }

}

JLabels (like most Aqua controls) are setOpaque(false) by default. If you put the label on a panel (which is setOpaque(true)), it's will be asked to paint it's background color before the label paints again.

Hope this help explains what's going on,
Mike Swingler
Java Runtime Engineer
Apple Inc.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Text rendering artifacts (From: Ken Orr <email@hidden>)
 >Re: Text rendering artifacts (From: Mike Swingler <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.