Beans that use JOGL

I want to create a Swing user interface component (a java bean) which displays a 3D view of a model. The natural way to do it would be to extend the GLCanvas class of JOGL and add the extra functionality that I need, but unfortunately that possibility is precluded by the JOGL design decision to create GLCanvas instances only through an object factory (GLDrawableFactory), which also complicates its use in GUI editors.

The only other option that I see is to have my component contain an instance of a GLDrawable which the component manages behind the scenes, and to somehow copy the image created on the GLDrawable to my component each time I’m asked to paint. This seems needlessly inefficient, however, and I’m not sure if the GLDrawable will render anything at all if it’s not actively and visibly used in the GUI. There also seem to be some threading issues due to the different painting methods of JOGL and AWT/Swing.

I’d be very grateful if anyone could give me some help on how I might go about creating such a component, given these constraints!

“Prefer composition over inheritance” ;D . Just kidding. You need not inherit from GLCanvas. You can inherit from AWT Container class, for instance, and add the GLCanvas inside it. You don’t need to copy the actual image produced by GLCanvas (because the GLCanvas is visible anyways). Make the GLCanvas accessible by a getter, so that the user can access the GLDrawable interface. By attaching an Animator to the GLCanvas, you’ll get continuous rendering (no need to trigger the painting of GLCanvas with a repaint event…).

now there’s a cunning idea… i’m new to all this AWT stuff, and think it would’ve been a while before I’d come up with anything like that - I’ll give it a go! thanks very much! :slight_smile: