Hi, gurus,

Can any one let me know why and how the canvas3d object gets 
the focus event and therefore the key event after Behavior 
objects are added to the scene graph?

What I want to do is 
I want to get the key event from the canvas3d without having 
any Behavior object in my scene, but I found out that if I don't 
have any Behavior object in my scene, I couldn't even get the focus. 

The following snippet codes are part of modifications to the demo 
program in the "Text2D" directory,

c.addFocusListener (new FocusListener () {
                public void focusGained (FocusEvent e) {
                        System.out.println ("focus gained");
                        System.out.println ("e.getSource = " + e.getSource());
                        Canvas3D cc = (Canvas3D)e.getSource();
                        cc.addKeyListener (new KeyAdapter () {
                                public void keyTyped (KeyEvent ex) {
                                        System.out.println ("key typed : = " + 
ex.getKeyChar());
                                }
                        });
                }
                public void focusLost (FocusEvent e) {
                        System.out.println ("focus lost");
                        //Canvas3D)e.getSource()).removeKeyListener ();
                        
                }
        });
        c.addMouseListener (new MouseAdapter () {
                public void mouseEntered (MouseEvent e){
                        System.out.println ("mosue entered");
                }
        });
        
        JPanel p = new JPanel ();
        JButton b = new JButton ("button");
        p.add (b);
        add ("North", p);

However, if the following line is commented

scene.addChild(navigator);

No focus is transferred to the canvas3d any more and therefore no 
output to the standard output.

Can anybody take a look and give me some hints?

Thanks,

Dongming Zhang


------------------------------------------
Dongming Zhang
System Analyst/Senior Programmer
Interactive Network Technologies, Inc.
Phone: 713-975-7434 Fax: 713-975-1120
http://www.int.com
Email: [EMAIL PROTECTED]
------------------------------------------ 
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to