AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
HyperlinkEvent typedict
 
A HyperlinkEvent is an event that can be handled by a JTextPane, when it is displaying HTML and the user clicks on or moves the pointer into or out of a hypertext link. The fields in a HyperlinkEvent are:
href A String that represents the description of the hypertext link.
id An Object that must be an int or String, that identifies the type of this event. A value that is a String must be the name of an event handler that can process this event. A value that is an int must be a number that the yoix.event.HandlerID dictionary associates with an event handler that can process this event.

In practice, id is only used when you build an event that gets handed to postEvent, and in that case the value assigned to id is almost always a String.

JTextPane is the only component that can receive HyperlinkEvents, but they only arrive if the component has defined one or more of the event handlers listed below.
 
 Event Handlers:   hyperlinkActivated, hyperlinkEntered, hyperlinkExited
 
 Example:   The program,
import yoix.*.*;

JFrame f = {
    Array layout = {
        new JTextPane {
            String text = "<a href=http://www.yoix.org/>Yoix</a>";
            int    mode = 1;         // means HTML
            int    edit = FALSE;     // currently required

            hyperlinkActivated(Event e) {
                Stream fp;

                if ((fp = open(e.href, "r")) != NULL) {
                    printf("%s\n", readStream(fp));
                    close(fp);
                }
            }

            hyperlinkEntered(Event e) {
                printf("hyperlinkEntered: e=%O\n", e);
            }

            hyperlinkExited(Event e) {
                printf("hyperlinkExited: e=%O\n", e);
            }
        },
    };
};

f.visible = TRUE;
puts a JTextPane configured to display HTML in a frame and defines three functions that handle HyperlinkEvents. Move the pointer into and out of the hypertext link or click on it and the appropriate event handlers will be called.
 
 See Also:   ActionEvent, AdjustmentEvent, CaretEvent, ChangeEvent, ComponentEvent, DragGestureEvent, DragSourceEvent, DropTargetEvent, Event, FocusEvent, InvocationEvent, invokeLater, isDispatchThread, ItemEvent, KeyEvent, ListSelectionEvent, MouseEvent, MouseWheelEvent, PaintEvent, postEvent, TextEvent, TreeSelectionEvent, WindowEvent

 

Yoix is a registered trademark of AT&T Intellectual Property.