Capturing Mouse Events at the Window Level

The layer event handler API allows to customize the behavior of INTViewer when a user clicks on a layer.

You also have the option to customize the behavior at the window level so that this behavior is the same across all layers of the same window.

In the example below, a NetBeans Top Component (on the right) shows the pertinent information about the last point clicked in the XSection window in focus.

The implementation of this tool consists of 3 classes:

  • a NetBeans top component (DemoPickTopComponent.java, designed with the built-in Swing/Matisse GUI editor, see Adding a TopComponent Window Walkthrough for an example)
  • an event (DemoPickEvent.java)
  • a window event handler (DemoPickWindowEventHandler.java)

The code of this handler is below:

The following layer.xml entry registers that window event handler:

    <folder name="ViewerWindowEventHandlers">
        <folder name="ViewerPlotXV">
            <file name="com-demo-pick-DemoPickWindowEventHandler.instance">
                <attr name="position" intvalue="9000"/>
            </file>
        </folder>
    </folder>

When a user clicks, the pick information is captured. This information consists of:

- the layer where the click occurred

- the trace where the click occurred

- the time/depth value of this click

An event is broadcasted with this pick info.

The top component listens for this event and displays this information to the end user.

The full code of this project is attached at the bottom of this page. Make sure you have registered the INTViewer platform prior to loading this project.