Example usage for javax.swing.event HyperlinkEvent getEventType

List of usage examples for javax.swing.event HyperlinkEvent getEventType

Introduction

In this page you can find the example usage for javax.swing.event HyperlinkEvent getEventType.

Prototype

public EventType getEventType() 

Source Link

Document

Gets the type of event.

Usage

From source file:uk.sipperfly.ui.Exactly.java

private void aboutAreaHyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_aboutAreaHyperlinkUpdate
    if (HyperlinkEvent.EventType.ACTIVATED.equals(evt.getEventType())) {
        System.out.println(evt.getURL());
        Desktop desktop = Desktop.getDesktop();
        try {//from   w w w . jav  a  2  s . c om
            desktop.browse(evt.getURL().toURI());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:uk.sipperfly.ui.Exactly.java

private void authorAreaHyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_authorAreaHyperlinkUpdate
    if (HyperlinkEvent.EventType.ACTIVATED.equals(evt.getEventType())) {
        System.out.println(evt.getURL());
        Desktop desktop = Desktop.getDesktop();
        try {//www.ja v a2s. c o m
            desktop.browse(evt.getURL().toURI());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:uk.sipperfly.ui.Exactly.java

private void contactAreaHyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_contactAreaHyperlinkUpdate
    if (HyperlinkEvent.EventType.ACTIVATED.equals(evt.getEventType())) {
        System.out.println(evt.getURL());
        Desktop desktop = Desktop.getDesktop();
        try {/*from   w  ww .  j ava  2 s.  c  om*/
            desktop.browse(evt.getURL().toURI());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:util.ui.UiUtilities.java

/**
 * Creates a Html EditorPane that holds a HTML-Help Text
 *
 * Links will be displayed and are clickable
 *
 * @param html/*  w  w  w.ja  va2  s  .co  m*/
 *          HTML-Text to display
 * @param background The color for the background.
 * @return EditorPane that holds a Help Text
 * @since 2.7.2
 */
public static JEditorPane createHtmlHelpTextArea(String html, Color background) {
    return createHtmlHelpTextArea(html, new HyperlinkListener() {
        private String mTooltip;

        public void hyperlinkUpdate(HyperlinkEvent evt) {
            JEditorPane pane = (JEditorPane) evt.getSource();
            if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                mTooltip = pane.getToolTipText();
                pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                if (evt.getURL() != null) {
                    pane.setToolTipText(evt.getURL().toExternalForm());
                }
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(Cursor.getDefaultCursor());
                pane.setToolTipText(mTooltip);
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                URL url = evt.getURL();
                if (url != null) {
                    Launch.openURL(url.toString());
                }
            }
        }
    }, background);
}