-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b03
-
x86
-
windows_xp
-
Verified
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows XP version 2002 sp 2
A DESCRIPTION OF THE PROBLEM :
With the system look and feel set (Windows XP or Windows Classic), if a JTextfield is filled until the first character in the textfield is clipped, it is not possible to scroll back to the start of the texfield.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Set the 'system' look and feel on a Windows XP os
- Create a JTexfield of fixed length
- Enter enough characters to fill the length of the textfield perfectly (e.g. "WXYZ")
- Now append an additional character such that the first character of contents becomes clipped (e.g. appending "a" to "WXYZ" should force part of the "W" to disappear from view)
- Try to scroll back to the beginning of the texfield contents (or press the HOME key)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should be possible to scroll to the beginning of the texfield's contents, and view the first character fully (e.g. with "WXYZa" as the contents, scolling back, should allow the "W" to be fully visible.
ACTUAL -
Upon scrolling back (or pressing HOME key), the caret disappears and the first character of the contents remains clipped (e.g. with "WXYZa" as the contents, after scrolling back to the start, the "W" remains clipped.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message produced.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* Testcase:
*
* - Run this class, a window with a textfield containing "WXYZ" should be displayed.
* - Append "a" to the end of the textfield contents.
* - Use back arrow to scroll back to the beginning of the textfield.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestJTextField extends JFrame
{
JPanel contentPane;
JPanel jPanel1 = new JPanel();
JTextField jTextField1 = new JTextField(4);
public static void main(String[] args){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
System.out.println(UIManager.getLookAndFeel());
TestJTextField frame = new TestJTextField();
frame.validate();
frame.setVisible(true);
}
public TestJTextField() {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new BorderLayout());
this.setSize(new Dimension(400, 300));
jTextField1.setText("WXYZ");
this.setTitle("Frame Title");
contentPane.add(jPanel1, BorderLayout.CENTER);
jPanel1.add("North",jTextField1);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This problem seems to be caused by the textfield margins that are set with the windows look and feel. Overwriting these margin settings such that no margins are used fixes the issue, but alters the look of the textfield.
e.g. in the above test case, replace
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
with
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.put("TextField.margin", new Insets(0,0,0,0));
}
catch(Exception e) {
e.printStackTrace();
}
Release Regression From : 1.4.2_12
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.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows XP version 2002 sp 2
A DESCRIPTION OF THE PROBLEM :
With the system look and feel set (Windows XP or Windows Classic), if a JTextfield is filled until the first character in the textfield is clipped, it is not possible to scroll back to the start of the texfield.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Set the 'system' look and feel on a Windows XP os
- Create a JTexfield of fixed length
- Enter enough characters to fill the length of the textfield perfectly (e.g. "WXYZ")
- Now append an additional character such that the first character of contents becomes clipped (e.g. appending "a" to "WXYZ" should force part of the "W" to disappear from view)
- Try to scroll back to the beginning of the texfield contents (or press the HOME key)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should be possible to scroll to the beginning of the texfield's contents, and view the first character fully (e.g. with "WXYZa" as the contents, scolling back, should allow the "W" to be fully visible.
ACTUAL -
Upon scrolling back (or pressing HOME key), the caret disappears and the first character of the contents remains clipped (e.g. with "WXYZa" as the contents, after scrolling back to the start, the "W" remains clipped.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message produced.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/**
* Testcase:
*
* - Run this class, a window with a textfield containing "WXYZ" should be displayed.
* - Append "a" to the end of the textfield contents.
* - Use back arrow to scroll back to the beginning of the textfield.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestJTextField extends JFrame
{
JPanel contentPane;
JPanel jPanel1 = new JPanel();
JTextField jTextField1 = new JTextField(4);
public static void main(String[] args){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
System.out.println(UIManager.getLookAndFeel());
TestJTextField frame = new TestJTextField();
frame.validate();
frame.setVisible(true);
}
public TestJTextField() {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new BorderLayout());
this.setSize(new Dimension(400, 300));
jTextField1.setText("WXYZ");
this.setTitle("Frame Title");
contentPane.add(jPanel1, BorderLayout.CENTER);
jPanel1.add("North",jTextField1);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This problem seems to be caused by the textfield margins that are set with the windows look and feel. Overwriting these margin settings such that no margins are used fixes the issue, but alters the look of the textfield.
e.g. in the above test case, replace
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
with
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.put("TextField.margin", new Insets(0,0,0,0));
}
catch(Exception e) {
e.printStackTrace();
}
Release Regression From : 1.4.2_12
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- relates to
-
JDK-4716362 Capital W cut off if first character in a JLabel or a JTextField
-
- Resolved
-