edu.umd.cs.piccolox.pswing
Class PSwingEventHandler

java.lang.Object
  extended by edu.umd.cs.piccolox.pswing.PSwingEventHandler
All Implemented Interfaces:
edu.umd.cs.piccolo.event.PInputEventListener, java.util.EventListener

public class PSwingEventHandler
extends java.lang.Object
implements edu.umd.cs.piccolo.event.PInputEventListener

Event handler to send MousePressed, MouseReleased, MouseMoved, MouseClicked, and MouseDragged events on Swing components within a PCanvas.

Author:
Ben Bederson, Lance Good, Sam Reid

Constructor Summary
PSwingEventHandler(PSwingCanvas canvas)
          Constructs a new PSwingEventHandler for the given canvas.
PSwingEventHandler(PSwingCanvas canvas, edu.umd.cs.piccolo.PNode listenNode)
          Constructs a new PSwingEventHandler for the given canvas, and a node that will receive the mouse events.
 
Method Summary
(package private)  void dispatchEvent(PSwingEvent pSwingMouseEvent, edu.umd.cs.piccolo.event.PInputEvent aEvent)
          Determines if any Swing components in Piccolo should receive the given MouseEvent and forwards the event to that component.
 boolean isActive()
          Returns if this event handler is active.
 void processEvent(edu.umd.cs.piccolo.event.PInputEvent aEvent, int type)
          Process a piccolo event and (if active) dispatch the corresponding Swing event.
(package private)  void setActive(boolean active)
          Sets whether this event handler can fire events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PSwingEventHandler

public PSwingEventHandler(PSwingCanvas canvas,
                          edu.umd.cs.piccolo.PNode listenNode)
Constructs a new PSwingEventHandler for the given canvas, and a node that will receive the mouse events.

Parameters:
canvas - the canvas associated with this PSwingEventHandler.
node - the node the mouse listeners will be attached to.

PSwingEventHandler

public PSwingEventHandler(PSwingCanvas canvas)
Constructs a new PSwingEventHandler for the given canvas.

Method Detail

setActive

void setActive(boolean active)
Sets whether this event handler can fire events.

Parameters:
active -

isActive

public boolean isActive()
Returns if this event handler is active.

Returns:
True if active

dispatchEvent

void dispatchEvent(PSwingEvent pSwingMouseEvent,
                   edu.umd.cs.piccolo.event.PInputEvent aEvent)
Determines if any Swing components in Piccolo should receive the given MouseEvent and forwards the event to that component. However, mouseEntered and mouseExited are independent of the buttons. Also, notice the notes on mouseEntered and mouseExited.

Parameters:
pSwingMouseEvent -
aEvent -

processEvent

public void processEvent(edu.umd.cs.piccolo.event.PInputEvent aEvent,
                         int type)
Process a piccolo event and (if active) dispatch the corresponding Swing event.

Specified by:
processEvent in interface edu.umd.cs.piccolo.event.PInputEventListener
Parameters:
aEvent -
type -