Archived

This topic is now archived and is closed to further replies.

a2k

[java] OpenGL and Swing

Recommended Posts

a2k    124
i''m using the Magician binding, and it said somewheres in the documentation that it doesn''t fully work with Swing. Has anyone tried using Swing in their OpenGL apps/applets? a2k

Share this post


Link to post
Share on other sites
Jerry Lynn    122
I have a little source code for a Magician based game engine that used Swing components (just a side project that I haven''t worked on in months). You basically have the same situation as any time you mix a heavy weight (GLComponent) and a light weight component. I believe there is an article on Javasoft.com on issues to watch when doing this.

I use absolute position for placing all of my components, so the heavy weight and light weight components never overlap.

If you all promise not to laugh hysterically at the trashy state of the code, I will post what little I have to the FAQ site this weekend (though I can''t say it will be of much use).

Share this post


Link to post
Share on other sites
GKW    200
somelightweightcomponent.setLightWeightPopupEnabled( false );

Works just fine. All the apps on my site are swing. I even, finally, got japplets to work with magician.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

Share this post


Link to post
Share on other sites
a2k    124
okay, so help me clarify here. um, what are lightweight/heavyweight components? and how can i make them work with ogl/swing? i''m just allowed to use heavyweight components? is that it?

lightweight components are just like floatable stuffs, no?

a2k

Share this post


Link to post
Share on other sites
GKW    200
I believe that lightweight components use the drawing facilities of the heavyweight components. For example JPopupMenu''s don''t automatically get their own painting methods. They will instead look to the JFrame or JApplet(heavyweights) that it is in to paint itself. I think they did this to speed things up and save some memory. The effect of this is if you have lightweight components in an enviornment that has non-swing components then the lightweight component may be drawn over. GLComponent is based on AWTCanvas. It is heavyweight and does not support lightweight swing components. It will draw over a lightweight component. Not all floating components are lightweight. Not all nonfloating components are heavyweight. By using the setLightWeightPopupEnabled( false ) for JPopupMenu''s you tell it that it needs to do its own repainting. This allows it to draw over a heavyweight component.

I wanrned you! Didn''t I warn you?! That colored chalk was forged by Lucifer himself!

Share this post


Link to post
Share on other sites