String () { Document doc = getDocument(); int start = getSelectionStart(); int end = getSelectionEnd(); try { Position p0 = doc.createPosition(start); Position p1 = doc.createPosition(end); StringWriter sw = new StringWriter(p1.getOffset() - p0.getOffset()); getEditorKit().write(sw, doc, p0.getOffset(), p1.getOffset() - p0.getOffset()); return StringUtil.removeHtmlTags(sw.toString()); } catch (BadLocationException | IOException ignored) { } return super.getSelectedText(); }