-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versione 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I receive an unexpected IllegalArgumentException, if I try to use Font in this way:
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.font.TextAttribute;
public class UnderlineEntryFieldTest {
public static void main(String[] unused) throws Exception {
Map map = new Hashtable();
map.put(TextAttribute.FAMILY, "courier italic");
map.put(TextAttribute.SIZE, new Float(28.0));
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
Font font = new Font(map);
JFrame f = new JFrame("!!!!!!!!!!");
f.setSize(500, 500);
f.setLocationRelativeTo(null);
f.getContentPane().setLayout(new java.awt.GridLayout(1,0));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField tf = new JTextField();
tf.setFont(font);
f.getContentPane().add(tf);
tf.setText("gianni");
f.setVisible(true);
}
}
Note if you remove the 11th row:
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
the Exception doesn't occur.
In previous release all works fine.
BstRegards
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
copy, paste and compile the source code in the Description.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JTextField is correctly shown
ACTUAL -
An exception is returned
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IllegalArgumentException: Zero length string passed to TextLayout constructor.
at java.awt.font.TextLayout.<init>(Unknown Source)
at sun.font.FontDesignMetrics.charsWidth(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextWidth(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextWidth(Unknown Source)
at javax.swing.text.PlainView.getLineWidth(Unknown Source)
at javax.swing.text.PlainView.calculateLongestLine(Unknown Source)
at javax.swing.text.PlainView.updateMetrics(Unknown Source)
at javax.swing.text.PlainView.updateDamage(Unknown Source)
at javax.swing.text.PlainView.insertUpdate(Unknown Source)
at javax.swing.text.FieldView.insertUpdate(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(Unknown Source)
at javax.swing.text.AbstractDocument.fireInsertUpdate(Unknown Source)
at javax.swing.text.AbstractDocument.handleInsertString(Unknown Source)
at javax.swing.text.AbstractDocument.insertString(Unknown Source)
at javax.swing.text.PlainDocument.insertString(Unknown Source)
at javax.swing.text.AbstractDocument.replace(Unknown Source)
at javax.swing.text.JTextComponent.setText(Unknown Source)
at UnderlineEntryFieldTest.main(UnderlineEntryFieldTest.java:21)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.font.TextAttribute;
public class UnderlineEntryFieldTest {
public static void main(String[] unused) throws Exception {
Map map = new Hashtable();
map.put(TextAttribute.FAMILY, "courier italic");
map.put(TextAttribute.SIZE, new Float(28.0));
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
Font font = new Font(map);
JFrame f = new JFrame("!!!!!!!!!!");
f.setSize(500, 500);
f.setLocationRelativeTo(null);
f.getContentPane().setLayout(new java.awt.GridLayout(1,0));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField tf = new JTextField();
tf.setFont(font);
f.getContentPane().add(tf);
tf.setText("gianni");
f.setVisible(true);
}
}
---------- END SOURCE ----------
Release Regression From : 5.0u9
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versione 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I receive an unexpected IllegalArgumentException, if I try to use Font in this way:
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.font.TextAttribute;
public class UnderlineEntryFieldTest {
public static void main(String[] unused) throws Exception {
Map map = new Hashtable();
map.put(TextAttribute.FAMILY, "courier italic");
map.put(TextAttribute.SIZE, new Float(28.0));
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
Font font = new Font(map);
JFrame f = new JFrame("!!!!!!!!!!");
f.setSize(500, 500);
f.setLocationRelativeTo(null);
f.getContentPane().setLayout(new java.awt.GridLayout(1,0));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField tf = new JTextField();
tf.setFont(font);
f.getContentPane().add(tf);
tf.setText("gianni");
f.setVisible(true);
}
}
Note if you remove the 11th row:
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
the Exception doesn't occur.
In previous release all works fine.
BstRegards
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
copy, paste and compile the source code in the Description.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JTextField is correctly shown
ACTUAL -
An exception is returned
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IllegalArgumentException: Zero length string passed to TextLayout constructor.
at java.awt.font.TextLayout.<init>(Unknown Source)
at sun.font.FontDesignMetrics.charsWidth(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextWidth(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextWidth(Unknown Source)
at javax.swing.text.PlainView.getLineWidth(Unknown Source)
at javax.swing.text.PlainView.calculateLongestLine(Unknown Source)
at javax.swing.text.PlainView.updateMetrics(Unknown Source)
at javax.swing.text.PlainView.updateDamage(Unknown Source)
at javax.swing.text.PlainView.insertUpdate(Unknown Source)
at javax.swing.text.FieldView.insertUpdate(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(Unknown Source)
at javax.swing.text.AbstractDocument.fireInsertUpdate(Unknown Source)
at javax.swing.text.AbstractDocument.handleInsertString(Unknown Source)
at javax.swing.text.AbstractDocument.insertString(Unknown Source)
at javax.swing.text.PlainDocument.insertString(Unknown Source)
at javax.swing.text.AbstractDocument.replace(Unknown Source)
at javax.swing.text.JTextComponent.setText(Unknown Source)
at UnderlineEntryFieldTest.main(UnderlineEntryFieldTest.java:21)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.font.TextAttribute;
public class UnderlineEntryFieldTest {
public static void main(String[] unused) throws Exception {
Map map = new Hashtable();
map.put(TextAttribute.FAMILY, "courier italic");
map.put(TextAttribute.SIZE, new Float(28.0));
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
Font font = new Font(map);
JFrame f = new JFrame("!!!!!!!!!!");
f.setSize(500, 500);
f.setLocationRelativeTo(null);
f.getContentPane().setLayout(new java.awt.GridLayout(1,0));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField tf = new JTextField();
tf.setFont(font);
f.getContentPane().add(tf);
tf.setText("gianni");
f.setVisible(true);
}
}
---------- END SOURCE ----------
Release Regression From : 5.0u9
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- duplicates
-
JDK-6478336 Exception measuring zero length string when font has layout attributes.
-
- Closed
-