Re: Spread Sheet Mouse Listeners

Hi Rick,

> kewl thanx for that...It all worked except for one prob... The popup
> menu needs the location of the mouse click so that it can show the
> menu in the right spot... How would I get the mouse position.
> Also I need to recognise double click events...How would i do
> that???

This is possible but will take some work.  The problem is
that you are using a high-level class (FancySSCell) but
want to have detailed control over the behavior of low
level classes (MouseHelper, and MouseBehaviorJ2D or
MouseBehaviorJ3D or both, depending on whether you are
using Java2D, Java3D or both).

Here's what you need to do:

1. Define an extension of visad.MouseHelper that overrides
the processEvent() method to do what you want with mouse
clicks, then invokes super.processEvent() so MouseHelper can
do its work.

2. Define extensions of visad.java3d.MouseBehaviorJ3D and/or
visad.java2d.MouseBehaviorJ2D whose constructors construct
your extension of MouseHelper rather than MouseHelper.

3. Define extensions of visad.java2d.DefaultDisplayRendererJ2D,
visad.java3d.DefaultDisplayRendererJ3D and
visad.java3d.TwoDDisplayRendererJ3D to override the
createSceneGraph() method to construct your extensions of
MouseBehaviorJ2D and MouseBehaviorJ3D, rather than
MouseBehaviorJ2D and MouseBehaviorJ3D.

4.  Define an extension of to override
the setDimension() and setDimClone() methods of BasicSSCell
to replace 'new DisplayImplJ3D' and 'new DisplayImplJ2D'
constructor calls with calls that supply your extensions
of DefaultDisplayRendererJ2D, DefaultDisplayRendererJ3D
and TwoDDisplayRendererJ3D.

5. In your application, use your extension of FancySSCell.

It would be nice if you could just add a mouse listener
to BasicSSCell.getDisplay().getComponent(), but Java3D
grabs all the events and the only way to get them back is
to insert a Behavior into the scene graph.  That might work
for Java2D spread sheet cells, though.

Good luck, and cheers,
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738

  • 1999 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: