Example usage for javax.media.j3d Canvas3D addKeyListener

List of usage examples for javax.media.j3d Canvas3D addKeyListener

Introduction

In this page you can find the example usage for javax.media.j3d Canvas3D addKeyListener.

Prototype

public synchronized void addKeyListener(KeyListener l) 

Source Link

Document

Adds the specified key listener to receive key events from this component.

Usage

From source file:BouncingBall.java

public BouncingBall() {
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config);
    add("Center", c);
    c.addKeyListener(this);
    timer = new Timer(100, this);
    //timer.start();
    Panel p = new Panel();
    p.add(go);/*from   www. j  a  v  a2 s.  c o m*/
    add("North", p);
    go.addActionListener(this);
    go.addKeyListener(this);
    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();

    SimpleUniverse u = new SimpleUniverse(c);
    u.getViewingPlatform().setNominalViewingTransform();
    u.addBranchGraph(scene);
}