Code example for JTextComponent

Methods: getSelectionEndgetSelectionStart

0
 
    @Override 
    public void actionPerformed(JTextComponent target, SyntaxDocument sdoc,
            int dot, ActionEvent e) {
        if (mustHaveSelection) {
            if (target.getSelectionEnd() == target.getSelectionStart()) {
                return; 
            } 
        } 
        if (wholeLines) {
            if(tlines == null) {
                tlines = template.split("\n");
            } 
            ActionUtils.insertLinesTemplate(target, tlines);
        } else { 
            ActionUtils.insertSimpleTemplate(target, template);
        } 
    } 
 
    public void setWholeLines(String value) {
        wholeLines = Boolean.parseBoolean(value);