-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.1
-
x86
-
windows_98
Name: boT120536 Date: 02/15/2001
java version "1.3.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)
I've tried searching for an exact duplicate of this
bug but couldn't find one. The closest report seems
to be 4140220. Maybe it's related.
===
When using Font("Dialog", Font.PLAIN, 11) as the font
in a JTextComponent, the text will not render properly
- it starts at the wrong position (one pixel to the left
of where it should be). This also has the effect that
the caret will appear "on top" of each character instead
of "just before" it. Other font sizes such as 10pt,
12pt or 13pt do not show this problem. See the
attached test case for a demonstration of the issue
(by the way, NetBeans, which also uses an 11pt font,
is affected too). Again, to clarify, this is not
about wide characters being clipped but the whole
text being somehow shifted one pixel to the left
(when compared to other font sizes).
===
import java.awt.*;
import javax.swing.*;
public class FontProblem extends JFrame {
public FontProblem() {
super("FontProblem");
JPanel pnl = new JPanel();
pnl.setLayout(new GridBagLayout());
for (int pt = 13; pt >= 10; pt--) {
JLabel lbl = new JLabel("JTextField using Font(\"Dialog\", "
+ "Font.PLAIN, " + pt + ")");
if (pt == 11) {
lbl.setForeground(Color.red);
}
pnl.add(lbl, new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 0, 0,
GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(8, 8, 0, 8), 0, 0));
JTextField tf = new JTextField();
tf.setFont(new Font("Dialog", Font.PLAIN, pt));
tf.setText("Demo Text");
pnl.add(tf, new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 8, 0, 8), 0, 0));
}
pnl.add(Box.createGlue(), new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 1, 1,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(8, 8, 8, 8), 0, 0));
setContentPane(pnl);
pack();
setLocation((getToolkit().getScreenSize().width - getWidth()) / 2,
((getToolkit().getScreenSize().height) - getHeight()) / 2);
}
public static void main(String[] args) {
new FontProblem().setVisible(true);
}
}
(Review ID: 117062)
======================================================================
- duplicates
-
JDK-4140220 JLabel cuts off front of 'W' if it begins the text with 11pt SansSerif font
-
- Closed
-