I am using the following code but "end" and "start" is not exactly the "end" and "start" of the selected text in JeditorPane.
JEditorPane note = new JEditorPane(); int end; int start; public void GetText() throws Exception{ query = note.getSelectedText(); end=note.getSelectionEnd(); start=note.getSelectionStart(); }