TopComponents, LookupEvents and LookupListeners
The tutorial has described how to extend INTViewer programmatically. Here is a brief explanation of the NetBeans/Swing objects involved:
TopComponents
A org.openide.windows.TopComponent is an embeddable visual component to be displayed in NetBeans. This is the basic unit of display--windows should not be created directly, but rather use this class. A top component may correspond to a single window, but may also be a tab (e.g.) in a window.
In the tutorial, the "traceInfo" window is a TopComponent object. The traceInfoTopComponent object extends org.openide.windows.TopComponent.
More information about creating and manipulating TopComponent windows is available.
LookupEvents
A org.openide.util.LookupEvent describes a change of selection.
When a current selection is changed, an object of the type org.openide.util.LookupEvent is created.
LookupListeners
A org.openide.util.LookupListener is a listener for changes in lookup.
When a new layer is loaded, the "traceInfo" window automatically displays the number of traces found. To achieve this result, the "traceInfo" needs to detect that a new layer was loaded.
This detection is implemented in three places in the implementation of traceInfoTopComponent:
- The traceInfoTopComponent object registers the Lookup Listener (see implementation in Layers and Readers) to indicate that it should be informed of changes in selections
- The traceInfoTopComponent object implements org.openide.util.LookupListener,
- The traceInfoTopComponent object overrides the resultChanged(LookupEvent evt) method of org.openide.util.LookupListener to act upon that change
More information about window and layer selection is available.