Bug ID 4132856: JTextField with a fractionally-scaled font doesn't
work correctly in 1.5.0_02.
In the sample below, the unscaled font and the font scaled by a
factor of 2.0 both work correctly; the font scaled by a factor of 1.5
fails in Java 1.5.0_02, but works correctly in Java 1.4.2_07.
Compile the program below and compare the behaviour in 1.4.2 and 1.5.0:
(1) Double-click in one of the 1.5x-scaled controls; it doesn't
select the complete text.
(2) Cursor through one of those controls; the cursor doesn't stay in
synch with character breaks.
(3) Type a large number of characters that are either much narrower
("i") or wider ("W") than the average; very quickly, you will see the
cursor get out of sync with the characters.
Tested on Mac OS X 10.4.1 using current released versions of Java.
public class ScaledText extends JFrame
{
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel
(UIManager.getSystemLookAndFeelClassName());
}
catch (Throwable t)
{
t.printStackTrace();
}
ScaledText text = new ScaledText();
text.show();
}
public ScaledText()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
Font font1 = new Font("Courier",Font.PLAIN,12);
Font font2 = font1.deriveFont
(AffineTransform.getScaleInstance(1.5,1.5));
Font font3 = font1.deriveFont
(AffineTransform.getScaleInstance(2,2));
JTextField text1 = new JTextField(font1.toString());
text1.setFont(font1);
JTextField text2 = new JTextField(font2.toString());
text2.setFont(font2);
JTextField text3 = new JTextField(font3.toString());
text3.setFont(font3);
JFormattedTextField text4 = new JFormattedTextField
(font1.toString());
text4.setFont(font1);
JFormattedTextField text5 = new JFormattedTextField
(font2.toString());
text5.setFont(font2);
JFormattedTextField text6 = new JFormattedTextField
(font3.toString());
text6.setFont(font3);
Box b = new Box(BoxLayout.Y_AXIS);
b.add(Box.createVerticalStrut(30));
b.add(text1);
b.add(Box.createVerticalStrut(30));
b.add(text2);
b.add(Box.createVerticalStrut(30));
b.add(text3);
b.add(Box.createVerticalStrut(30));
b.add(text4);
b.add(Box.createVerticalStrut(30));
b.add(text5);
b.add(Box.createVerticalStrut(30));
b.add(text6);
getContentPane().add("Center", b);
_______________________________________________
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