Code example for HTMLDocument

Methods: remove

0
            int offset = editor.getSelectionStart();
 
            HTMLEditorKit kit = (HTMLEditorKit)editor.getEditorKit();
            try 
            { 
                htmlDocument.remove(offset, editor.getSelectionEnd() - offset);
                kit.insertHTML(htmlDocument, offset, txt, 0, 0, HTML.Tag.A);
            } catch (Throwable e)
            { 
                LOG.log(Level.WARNING, "Failed to insert link", e);
            } 
        } else 
        { 
            editor.replaceSelection(txt);
        } 
    } 
 
    /** 
     * Returns the text which is currently selected. 
     * 
Connect your IDE to all the code out there  Get Codota for Java