Hello Francois,

At 11:05 07.08.00 -0500, you wrote:
>Hello,
>
>Does anybody know how redirect a key event happening in a canvas 3d to
>the swing components?
>
>I my project, I want to navigate throught the world with arrows keys and I
>also
>need to enable some of my swing component in the menubar with hotkeys.
>
>Is it possible? Is there somebody who knows how to do that?
>Any answer are welcome

I had a similar problem and I managed to solve it at least to my own
satisfaction.

I embed my Canvas3D in part of a JFrame, and use the remaining space for
something I call a "control panel" with buttons and text fields I use to
move my
point of view around in space. This much is straightforward; I trust you have
no problem hooking up ActionListeners.

When my fingers got tired of clicking the mouse on the buttons, I built a
keyboard interface that works with the arrow keys. To this end, I connected
a KeyListener to every control on the panel. Thus, as long as the panel (which
is a JComponents) or some component on it has the focus, key events are
captured and cause actions in my interface.

In a purely Swing world, this may have been simpler with
registerKeyboardAction()
on the panel rather than attaching KeyListeners to everything, but it works
fine for
me so I moved on to other parts of my project.

One remaining problem is that KeyEvents are not captured when the focus is
off the panel, i.e. on the Canvas3D. If your users mouse around on the canvas,
this will be the case most of the time. If this were a problem for me, I
think I
could solve it by attaching my KeyListener to the Canvas3D as well.

You are welcome to look at my code at: http://www.smotricz.com/Java3D/,
where I just dumped a snapshot of my current project. The stuff that interests
you is in Nav3D.java .

For truly expert advice beyond my stumbling in the dark, I highly recommend
_3D User Interfaces with Java 3D_ by Jon Barilleaux. It's described at the very
bottom of this page: http://java.sun.com/products/java-media/3D/collateral/
and the link leads to the publisher's site, where you can download a .PDF
version
of the book for 13 Dollars something, if I remember correctly. Barilleaux shows
a wealth of knowledge on stuff like this.

Hth,

-Carl-

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to