-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
x86
-
windows_nt
Name: rl66838 Date: 07/12/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
On Windows, anti-aliased JLabel and JButton are not useable because
their size is initialized with the length of not a-a text, which
is different of the length of a-a text (a ... appears).
Similarly, selecting text in a a-a JTextComponent shows a colored
background that does not cover the proper range of selected text.
This is somewhat related to bug 4233886, but this one is closed.
Sample code :
import javax.swing.*;
import java.awt.*;
class AA extends JFrame {
public static void main(String[] s) {
new AA();
}
AA() {
getContentPane().setLayout(new FlowLayout());
getContentPane().add(new AAText("a long long long line of text"));
getContentPane().add(new AAButton("button"));
pack();
show();
}
}
class AAText extends JTextArea {
AAText(String s) {
super(s, 4, 40);
}
public void paintComponent(Graphics g) {
((Graphics2D)g).setRenderingHint
(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g);
}
}
class AAButton extends JButton {
AAButton(String s) {
super(s);
}
public void paintComponent(Graphics g) {
((Graphics2D)g).setRenderingHint
(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g);
}
}
(Review ID: 107116)
======================================================================
- duplicates
-
JDK-4233886 Anti-aliased text renders longer than it should
-
- Resolved
-