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
TreeSelectionEvent typedict
 
A TreeSelectionEvent is a Swing event that indicates the current selection in a JTree has changed. The fields in a TreeSelectionEvent are:
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.

items An Array, arranged in pairs, that indicate which nodes in the JTree were added or removed from the selection. The first element in a pair is a JTreeNode and the second element in the pair is an int the is 1 if the node was added and 0 if it was removed from the selection.
JTree is the only component that can receive TreeSelectionEvents, but they only arrive if the component has defined a valueChanged event handler.
 
 Event Handlers:   valueChanged
 
 Example:   The program,
import yoix.*.*;

JFrame f = {
    Array layout = {
        new JTree {
            Color background = Color.white;

            JTreeNode top = {
                String text = "The C Programming Language";
                Array children = {
                    new JTreeNode {
                        String text = "Introduction";
                    },
                    new JTreeNode {                 
                        String text = "A Tutorial Introduction";
                    },
                    new JTreeNode {
                        String text = "Types, Operators and Expressions";
                    },  
                };
            };   

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

f.visible = TRUE;
puts a small JTree in a JFrame and defines a handler for TreeSelectionEvents that dumps the items array each time an event arrives.
 
 See Also:   ActionEvent, AdjustmentEvent, CaretEvent, ChangeEvent, ComponentEvent, DragGestureEvent, DragSourceEvent, DropTargetEvent, Event, FocusEvent, HyperlinkEvent, InvocationEvent, invokeLater, isDispatchThread, ItemEvent, KeyEvent, ListSelectionEvent, MouseEvent, MouseWheelEvent, PaintEvent, postEvent, TextEvent, WindowEvent

 

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