com.sun.j3d.utils.behaviors.keyboard
Class KeyNavigatorBehavior

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.Node
          extended by javax.media.j3d.Leaf
              extended by javax.media.j3d.Behavior
                  extended by com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener

public class KeyNavigatorBehavior
extends Behavior
implements java.awt.event.KeyListener

This class is a simple behavior that invokes the KeyNavigator to modify the view platform transform.


Field Summary
 
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
KeyNavigatorBehavior(java.awt.Component c, TransformGroup targetTG)
          Constructs a key navigator behavior that uses AWT listeners and behavior posts rather than WakeupOnAWTEvent.
KeyNavigatorBehavior(TransformGroup targetTG)
          Constructs a new key navigator behavior node that operates on the specified transform group.
 
Method Summary
 void addListener(java.awt.Component c)
          Adds this behavior as a KeyListener to the specified component.
 void initialize()
          Override Behavior's initialize method to setup wakeup criteria.
 void keyPressed(java.awt.event.KeyEvent evt)
           
 void keyReleased(java.awt.event.KeyEvent evt)
           
 void keyTyped(java.awt.event.KeyEvent evt)
           
 void processStimulus(java.util.Enumeration criteria)
          Override Behavior's stimulus method to handle the event.
 
Methods inherited from class javax.media.j3d.Behavior
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn
 
Methods inherited from class javax.media.j3d.Node
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyNavigatorBehavior

public KeyNavigatorBehavior(TransformGroup targetTG)
Constructs a new key navigator behavior node that operates on the specified transform group.

Parameters:
targetTG - the target transform group

KeyNavigatorBehavior

public KeyNavigatorBehavior(java.awt.Component c,
                            TransformGroup targetTG)
Constructs a key navigator behavior that uses AWT listeners and behavior posts rather than WakeupOnAWTEvent. The behavior is added to the specified Component and works on the given TransformGroup. A null component can be passed to specify the behavior should use listeners. Components can then be added to the behavior with the addListener(Component c) method.

Parameters:
c - The component to add the KeyListener to.
targetTG - The target transform group.
Since:
Java 3D 1.2.1
Method Detail

initialize

public void initialize()
Override Behavior's initialize method to setup wakeup criteria.

Specified by:
initialize in class Behavior

processStimulus

public void processStimulus(java.util.Enumeration criteria)
Override Behavior's stimulus method to handle the event.

Specified by:
processStimulus in class Behavior
Parameters:
criteria - an enumeration of triggered wakeup criteria for this behavior

addListener

public void addListener(java.awt.Component c)
Adds this behavior as a KeyListener to the specified component. This method can only be called if the behavior was created with one of the constructors that takes a Component as a parameter.

Parameters:
c - The component to add the KeyListener to.
Throws:
java.lang.IllegalStateException - if the behavior was not created as a listener
Since:
Java 3D 1.2.1

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Specified by:
keyTyped in interface java.awt.event.KeyListener


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.