Java JEditorPane addHyperLinkListener(JEditorPane editorPane)

Here you can find the source of addHyperLinkListener(JEditorPane editorPane)

Description

add Hyper Link Listener

License

Apache License

Declaration

public static void addHyperLinkListener(JEditorPane editorPane) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import java.awt.*;

public class Main {
    public static void addHyperLinkListener(JEditorPane editorPane) {
        editorPane.addHyperlinkListener(hyperlinkListener -> {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(hyperlinkListener.getEventType())) {
                Desktop desktop = Desktop.getDesktop();

                try {
                    desktop.browse(hyperlinkListener.getURL().toURI());
                } catch (Exception ex) {
                    ex.printStackTrace();
                }//from www. j  a  v  a 2s . c  o m
            }
        });
    }
}

Related

  1. addEditorPaneToOther(JEditorPane[] old, JEditorPane add)
  2. decorateStyleSheet(JEditorPane editor)
  3. displayEditorPaneWithNoBorderAndTranslucent(JEditorPane editorPane)
  4. emptyDoc(JEditorPane pane)
  5. enforceJEditorPaneFont(JEditorPane jEditorPane, Font font)