Example usage for javax.swing JEditorPane getToolTipText

List of usage examples for javax.swing JEditorPane getToolTipText

Introduction

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

Prototype

public String getToolTipText() 

Source Link

Document

Returns the tooltip string that has been set with setToolTipText.

Usage

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/*from   w ww .  jav a 2s .  com*/
 *          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);
}