Example usage for javax.swing JEditorPane addMouseListener

List of usage examples for javax.swing JEditorPane addMouseListener

Introduction

In this page you can find the example usage for javax.swing JEditorPane addMouseListener.

Prototype

public synchronized void addMouseListener(MouseListener l) 

Source Link

Document

Adds the specified mouse listener to receive mouse events from this component.

Usage

From source file:org.docx4all.swing.text.WordMLEditorKit.java

/**
 * Called when the kit is being installed into the a JEditorPane.
 * //from  w w w .ja v a 2  s. co  m
 * @param c
 *            the JEditorPane
 */
@Override
public void install(JEditorPane c) {
    super.install(c);

    c.addCaretListener(caretListener);
    c.addCaretListener(contentControlTracker);
    c.addMouseListener(mouseListener);
    c.addMouseMotionListener(mouseListener);
    c.addPropertyChangeListener(caretListener);
    caretListener.updateCaretElement(0, 0, c);

    initKeyBindings(c);
}

From source file:org.fit.cssbox.swingbox.SwingBoxEditorKit.java

@Override
public void install(JEditorPane c) {
    super.install(c);
    c.addMouseListener(mcontroller);
    c.addMouseMotionListener(mcontroller);
    component = c;/*from  w ww .j  a  v a 2 s.c  o m*/
}

From source file:org.mindswap.swoop.renderer.BaseEntityRenderer.java

/**
 * Create a JEditorPane given the contentType (text/plain or text/html)
 * and make other default settings (add hyperlink listener, editable false)
 * @param contentType/* w w w . j a  va2s . co  m*/
 * @return
 */
public static JEditorPane getEditorPane(String contentType, TermsDisplay TD) {
    JEditorPane editorPane = null;
    if (contentType.equals("text/plain"))
        editorPane = new JEditorPane();
    else if (contentType.equals("text/html")) {
        editorPane = new JEditorPane();
        editorPane.addHyperlinkListener(TD);
    } else if (contentType.equals("text/xml"))
        editorPane = new JEditorPane();
    else
        throw new RuntimeException("Cannot create an editor pane for content type " + contentType);

    editorPane.setEditable(false);
    editorPane.setContentType(contentType);

    // adding to UI listeners of TermsDisplay
    //editorPane.getDocument().addDocumentListener(TD);
    editorPane.addMouseListener(TD);
    editorPane.addKeyListener(TD);

    return editorPane;
}

From source file:org.mindswap.swoop.renderer.entity.TurtleEntityRenderer.java

public Component getDisplayComponent(SwoopDisplayPanel panel) {
    if (!(panel instanceof TermsDisplay))
        throw new IllegalArgumentException();

    JEditorPane editorPane = BaseEntityRenderer.getEditorPane(this.getContentType(), (TermsDisplay) panel);

    if (!editorEnabled) {
        return editorPane;
    } else {//w w  w . j  av  a  2  s.c  om
        editorPane.setEditable(true);
        // adding to UI listeners of TermsDisplay
        //editorPane.getDocument().addDocumentListener((TermsDisplay)panel);
        editorPane.addMouseListener((TermsDisplay) panel);
        editorPane.addKeyListener((TermsDisplay) panel);
    }
    return editorPane;
}