Code example for JTextComponent

Methods: getSelectionEndgetSelectionStart

0
 
    @Override 
    public void actionPerformed(JTextComponent target, SyntaxDocument sdoc,
            int dot, ActionEvent e) {
        try { 
            int st = sdoc.getLineStartOffset(target.getSelectionStart());
            int en = sdoc.getLineEndOffset(target.getSelectionEnd());
            sdoc.remove(st, en - st);
        } catch (BadLocationException ex) {
            Logger.getLogger(DeleteLinesAction.class.getName()).log(Level.SEVERE, null, ex);
        } 
    } 
} 
Contextual code suggestions in your IDE  Get Codota for Java