Java Code Examples for javax.swing.JEditorPane#isEditable()
The following examples show how to use
javax.swing.JEditorPane#isEditable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OQLEditor.java From netbeans with Apache License 2.0 | 6 votes |
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); } }
Example 2
Source File: OQLEditor.java From visualvm with GNU General Public License v2.0 | 6 votes |
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); } }
Example 3
Source File: StyledEditorKit.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 4
Source File: StyledEditorKit.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 5
Source File: StyledEditorKit.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 6
Source File: EditableLinkController.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@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); } }
Example 7
Source File: MouseController.java From SwingBox with GNU Lesser General Public License v3.0 | 5 votes |
@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); } } }
Example 8
Source File: StyledEditorKit.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 9
Source File: StyledEditorKit.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 10
Source File: StyledEditorKit.java From hottub with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 11
Source File: StyledEditorKit.java From Java8CN with Apache License 2.0 | 5 votes |
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"); } } }
Example 12
Source File: StyledEditorKit.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
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"); } } }
Example 13
Source File: StyledEditorKit.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 14
Source File: StyledEditorKit.java From Bytecoder with Apache License 2.0 | 5 votes |
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"); } } }
Example 15
Source File: StyledEditorKit.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 16
Source File: StyledEditorKit.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 17
Source File: StyledEditorKit.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 18
Source File: StyledEditorKit.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 19
Source File: StyledEditorKit.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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"); } } }
Example 20
Source File: MouseController.java From SwingBox with GNU Lesser General Public License v3.0 | 4 votes |
@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); } } }