FULL PRODUCT VERSION :
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6002]
A DESCRIPTION OF THE PROBLEM :
When text is placed in a TextArea with replaceRange() and insert(), this does not update the TextArea's "text" field with the text. Subsequently, when the TextArea is cleared with setText(null), it compares that the "text" field is empty, and so is the argument, and thus does not do anything. The text is not cleared from the TextArea, as it should be.
Apparently, the field "text" should be always kept in sync with the actual text in the TextArea, also in cases where replaceRange() and insert() is called.
Alternatively, the setText() should first get the actual text from the peer, before comparing to check if the TextArea contents are actually empty, and the text is being set to empty (in which case nothing needs to be done).
Currently, the TextArea erroneously thinks that it's still empty, when text has been added with replaceRange() and insert(), and the contents are set to empty with setText(null). This must be fixed.
REGRESSION. Last worked in version 7u25
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) run javac TextAreaTest.java
2) run java TextAreaTest
3) Observe the TextArea in the window
EXPECTED VERSUS ACTUAL BEHAVIOR :
TextArea is empty
TextArea still contains the text that was added via replaceRange() and insert()
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TextAreaTest
private TextArea textArea;
super("Text area bug test");
public void windowClosing(WindowEvent windowEvent)
this.textArea = new TextArea();
this.textArea.replaceRange("Some text", 0, 0);
this.textArea.insert("Some more text, ", 0);
public static void main(String args)
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
For example, TextArea.getText() resets the "text" field, making it work correctly.
However, this does not fix software that is already deployed.