Swing + Canvas3D

hi,

it’s well known that a swing component can’t be drawn on a Canvas3D because of the light- & heavyweight opposition.
In my case, it would really really really be usefull, nearly a must, to display swing components on top of Canvas3D.
I am wondering if there is any way to get around this.
Someone has an idea?

It’s one of those questions that comes up so often that you’d think there would be an FAQ on it somewhere :stuck_out_tongue:

I think most people who have done any j3d have run into it at some point- I worked on a swing and j3d application this summer that used both and apart from having to maintain a single Canvas3d the whole way through, to prevent some really messed up graphics effects, it mostly worked pretty much as one would expect.

Actually, you can even use multiple Canvas3D’s, but you should always contain them in a JPanel and let the JPanel manage the resizing.

The nastiness comes when you try to paint Swing components over the Canvas3D. You can do menu bars and dialogs, by setting the correct flag, but you’ll get flashing and other undesirable side-effects. If you want to draw stuff like Heads-Up Displays (HUDs) or such, then draw them in the 3D space using overlays.

I was getting a big black rectangle drawing outside the window my application was running in when I initialised a second Canvas3D - I think it is due to crappy graphics drivers on my system and some obscure effect of the GraphicsConfiguration system - so I was having to keep one and pass it between the different 3d parts of the application. It worked fine once I had got that happening.