editorgetDocumentreplaceStringeditorgetSelectionModelgetSelectionStart 报错 editorgetDocumentreplaceStringeditorgetSelectionModelgetSelectionStart 如何解决
这个代码段中的问题可能是缺少第二个参数,即要替换的字符串。您需要在第一个参数后添加要替换的字符串。例如:
editor.getDocument().replaceString(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), "替换的字符串");
这将使用选定的文本的起始和结束位置来替换选定的文本。如果您希望替换整个文档中的文本,可以使用以下代码:
editor.getDocument().replaceString(0, editor.getDocument().getTextLength(), "替换的字符串");
原文地址: https://www.cveoy.top/t/topic/bsIo 著作权归作者所有。请勿转载和采集!