Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java replaceRange()的替代品是什么;在JTextArea中,对于JTextPane?_Java_Swing_Awt - Fatal编程技术网

Java replaceRange()的替代品是什么;在JTextArea中,对于JTextPane?

Java replaceRange()的替代品是什么;在JTextArea中,对于JTextPane?,java,swing,awt,Java,Swing,Awt,我目前正在更新一个旧小程序的代码,并且正在从awt转换为swing。我想通过JTextPane比awt中的旧TextArea利用更多的定制功能 textArea.selectAll(); textArea.replaceRange("", textArea.getSelectionStart(), textArea.getSelectionEnd()); 如何使其与JTextPane兼容?下面是运行java*.java命令时出现的错误 chatPne.java:138: cannot find

我目前正在更新一个旧小程序的代码,并且正在从awt转换为swing。我想通过JTextPane比awt中的旧TextArea利用更多的定制功能

textArea.selectAll();
textArea.replaceRange("", textArea.getSelectionStart(),
textArea.getSelectionEnd());
如何使其与JTextPane兼容?下面是运行java*.java命令时出现的错误

chatPne.java:138: cannot find symbol
symbol  : method replaceRange(java.lang.String,int,int)
location: class javax.swing.JTextPane
                                textArea.replaceRange("", textArea.getSelectionStart(),
                                        ^

只需使用其中一种方法即可帮助您:以下是指向javadoc的链接

在您的示例中:

textArea.replaceSelection("");
就够了,

textArea.replaceSelection("");