edu.umd.cs.piccolox.pswing
Class PSwingEventHandler

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

public class PSwingEventHandler
extends Object
implements 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, 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, PInputEvent aEvent)
          Determines if any Swing components in Piccolo2D should receive the given MouseEvent and forwards the event to that component.
 boolean isActive()
          Returns if this event handler is active.
 void processEvent(PInputEvent aEvent, int type)
          Process a Piccolo2D 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,
                          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.
listenNode - the node the mouse listeners will be attached to.

PSwingEventHandler

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

Parameters:
canvas - to associate this event handler to
Method Detail

setActive

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

Parameters:
active - true if this event handler can fire events

isActive

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

Returns:
true if can fire events

dispatchEvent

void dispatchEvent(PSwingEvent pSwingMouseEvent,
                   PInputEvent aEvent)
Determines if any Swing components in Piccolo2D 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 - event being dispatched
aEvent - Piccolo2D event translation of the pSwingMouseEvent

processEvent

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

Specified by:
processEvent in interface PInputEventListener
Parameters:
aEvent - Piccolo2D event being tested for dispatch to swing
type - is not used in this method


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.