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?
<good_text.png><bad_text.png>
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.