javax.swing.JEditorPane#isEditable ( )源码实例Demo

下面列出了javax.swing.JEditorPane#isEditable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: OQLEditor.java
public void setEditable(boolean b) {
    JEditorPane editor = getEditor();
    if (editor.isEditable() == b) return;
    
    editor.setEditable(b);

    if (b) {
        if (lastBgColor != null) editor.setBackground(lastBgColor);
        if (lastCaret != null) editor.setCaret(lastCaret);
    } else {
        lastBgColor = editor.getBackground();
        lastCaret = editor.getCaret();
        editor.setBackground(disabledBgColor);
        editor.setCaret(nullCaret);
    }
}
 
源代码2 项目: visualvm   文件: OQLEditor.java
public void setEditable(boolean b) {
    JEditorPane editor = getEditor();
    if (editor.isEditable() == b) return;
    
    editor.setEditable(b);

    if (b) {
        if (lastBgColor != null) editor.setBackground(lastBgColor);
        if (lastCaret != null) editor.setCaret(lastCaret);
    } else {
        lastBgColor = editor.getBackground();
        lastCaret = editor.getCaret();
        editor.setBackground(disabledBgColor);
        editor.setCaret(nullCaret);
    }
}
 
源代码3 项目: jdk1.8-source-analysis   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码5 项目: TencentKona-8   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码6 项目: jdk8u60   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码7 项目: openjdk-jdk8u   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码9 项目: Bytecoder   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码10 项目: openjdk-jdk9   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码11 项目: jdk8u-jdk   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码12 项目: Java8CN   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码13 项目: hottub   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码14 项目: openjdk-8-source   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码15 项目: openjdk-8   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码16 项目: SwingBox   文件: MouseController.java
@Override
public void mouseClicked(MouseEvent e)
{
    JEditorPane editor = (JEditorPane) e.getSource();

    if (!editor.isEditable() && SwingUtilities.isLeftMouseButton(e))
    {
        Bias[] bias = new Bias[1];
        Point pt = new Point(e.getX(), e.getY());
        int pos = editor.getUI().viewToModel(editor, pt, bias);

        if (bias[0] == Position.Bias.Backward && pos > 0) pos--;

        //Point pt = new Point(e.getX(), e.getY());
        //int pos = editor.viewToModel(pt);
        // System.err.println("found position : " + pos);
        if (pos >= 0)
        {
            Element el = ((SwingBoxDocument) editor.getDocument()).getCharacterElement(pos);
            AttributeSet attr = el.getAttributes();
            Anchor anchor = (Anchor) attr.getAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE);

            if (anchor != null && anchor.isActive())
                createHyperLinkEvent(editor, el, anchor, EventType.ACTIVATED);
        }
    }

}
 
源代码17 项目: rapidminer-studio   文件: EditableLinkController.java
@Override
public void mouseClicked(MouseEvent e) {
	JEditorPane editor = (JEditorPane) e.getSource();

	if (editor.isEditable() && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() >= 2) {
		// make sure we do not start editing twice to avoid internal Java explosions
		editor.setEditable(false);
		super.mouseClicked(e);
		editor.setEditable(true);
	}

}
 
源代码18 项目: jdk8u-jdk   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码19 项目: jdk8u-dev-jdk   文件: StyledEditorKit.java
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
源代码20 项目: SwingBox   文件: MouseController.java
@Override
public void mouseMoved(MouseEvent e)
{
    JEditorPane editor = (JEditorPane) e.getSource();

    if (!editor.isEditable())
    {
        Bias[] bias = new Bias[1];
        Point pt = new Point(e.getX(), e.getY());
        int pos = editor.getUI().viewToModel(editor, pt, bias);

        if (bias[0] == Position.Bias.Backward && pos > 0) pos--;

        if (pos >= 0 && (editor.getDocument() instanceof StyledDocument))
        {
            Element elem = ((StyledDocument) editor.getDocument()).getCharacterElement(pos);
            Object bb = elem.getAttributes().getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
            Anchor anchor = (Anchor) elem.getAttributes().getAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE);
            //System.out.println("Pos: " + pos);
            //System.out.println("Elem: " + elem.getAttributes().getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE));
            //System.out.println("Anchor: " + anchor);

            if (elem != prevElem)
            {
                prevElem = elem;
                if (!anchor.isActive())
                {
                    if (bb != null && bb instanceof TextBox)
                        setCursor(editor, textCursor);
                    else
                        setCursor(editor, defaultCursor);
                }
            }
            
            if (anchor != prevAnchor)
            {
                if (prevAnchor == null)
                {
                    if (anchor.isActive())
                    {
                        createHyperLinkEvent(editor, elem, anchor, EventType.ENTERED);
                    }
                    prevAnchor = anchor;
                }
                else if (!prevAnchor.equalProperties(anchor.getProperties()))
                {
                    if (prevAnchor.isActive())
                    {
                        createHyperLinkEvent(editor, prevElem, prevAnchor, EventType.EXITED);
                    }

                    if (anchor.isActive())
                    {
                        createHyperLinkEvent(editor, elem, anchor, EventType.ENTERED);
                    }
                    prevAnchor = anchor;
                }

            }
        }
        else //nothing found
        {
            prevElem = null;
            if (prevAnchor != null && prevAnchor.isActive())
            {
                createHyperLinkEvent(editor, prevElem, prevAnchor, EventType.EXITED);
                prevAnchor = null;
            }   
            setCursor(editor, defaultCursor);
        }
    }
}