-
Bug
-
Resolution: Fixed
-
P3
-
1.2.2
-
kestrel
-
sparc
-
solaris_2.5.1
Name: akC57697 Date: 05/28/99
This bug was found by St.Petersburg Java SQE team (by Sergey Scherbakov).
JDK 1.2.2 method JEditorPane.replaceSelection(String content) replaces
selected text if content null or empty, but JavaDoc say:
public void replaceSelection(String content)
Replaces the currently selected content with new content
represented by the given string. If there is no selection
this amounts to an insert of the given text. If there is no
replacement text this amounts to a removal of the current
selection. The replacement text will have the attributes
currently defined for input. If the document is not editable,
beep and return. Then if the document is null, do nothing. If the
content to insert is null or empty, ignore it.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The example:
------------------------------------------------------------------------------------
import javax.swing.JEditorPane;
public class Test {
public static void main(String argv[]) {
JEditorPane c;
JEditorPane ja = new JEditorPane("text/plain", "Test string");
ja.select(0, 5);
System.out.println(ja.getText());
ja.replaceSelection(null);
System.out.println(ja.getText());
System.exit(0);
}
}
------------------------------------------------------------------------------------
Output :
Test string
string
======================================================================