-
Bug
-
Resolution: Fixed
-
P3
-
7u45
-
b89
-
windows_vista
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8142759 | emb-9 | Alexandr Scherbatiy | P3 | Resolved | Fixed | team |
JDK-8183721 | 8u161 | Unassigned | P3 | Resolved | Fixed | b01 |
JDK-8164491 | 8u152 | Mikhail Cherkasov | P3 | Resolved | Fixed | b01 |
JDK-8192457 | emb-8u161 | Unassigned | P3 | Resolved | Fixed | b01 |
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 :
EXPECTED -
TextArea is empty
ACTUAL -
TextArea still contains the text that was added via replaceRange() and insert()
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class TextAreaTest
extends Frame
{
private TextArea textArea;
private TextAreaTest()
{
super("Text area bug test");
setSize(720, 540);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent windowEvent)
{
setVisible(false);
dispose();
System.exit(0);
}
});
setLayout(new BorderLayout());
this.textArea = new TextArea();
add(this.textArea, BorderLayout.SOUTH);
setVisible(true);
this.textArea.replaceRange("Some text", 0, 0);
this.textArea.insert("Some more text, ", 0);
this.textArea.setText(null);
}
public static void main(String[] args)
{
new TextAreaTest();
}
}
---------- 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.
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 :
EXPECTED -
TextArea is empty
ACTUAL -
TextArea still contains the text that was added via replaceRange() and insert()
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class TextAreaTest
extends Frame
{
private TextArea textArea;
private TextAreaTest()
{
super("Text area bug test");
setSize(720, 540);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent windowEvent)
{
setVisible(false);
dispose();
System.exit(0);
}
});
setLayout(new BorderLayout());
this.textArea = new TextArea();
add(this.textArea, BorderLayout.SOUTH);
setVisible(true);
this.textArea.replaceRange("Some text", 0, 0);
this.textArea.insert("Some more text, ", 0);
this.textArea.setText(null);
}
public static void main(String[] args)
{
new TextAreaTest();
}
}
---------- 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.
- backported by
-
JDK-8142759 TextArea.replaceRange() and insert() are broken with setText(null)
- Resolved
-
JDK-8164491 TextArea.replaceRange() and insert() are broken with setText(null)
- Resolved
-
JDK-8183721 TextArea.replaceRange() and insert() are broken with setText(null)
- Resolved
-
JDK-8192457 TextArea.replaceRange() and insert() are broken with setText(null)
- Resolved
- relates to
-
JDK-7184365 closed/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest fails
- Closed