Embedding an "usual" JPanel into my scene ?

Hi folks,

this is my first post in this forum here, so, welcome everybody!

I’ve started jogl programming some days ago. Up to now, I have managed to detect mouseclicks in my scene ( ~> selecting/picking). What I would like to do now is the following:

Imagine a simple JPanel like eg,


JPanel pnl = new JPanel();
pnl.add(new JLabel("A test label"));
pnl.add(new JButton("first button"));
pnl.add(new JButton("second button"));
pnl.add(new JButton("third button"));

Now, say my scene contained a regular cube.

How can I embed my JPanel into one face of the cube?

This embedding of course would have to do more than just displaying the projected graphics of the panel,
also the event dispatching (mouseListener, mouseMotionListener, …) would have to be done somehow.

Thank you for your kind replies in advance,

with best regards,

Oliver

Hi,

seems like nobody understood my question, so here’s a new try:

I am searching for a possibility to integrate “normal” Swing GUIs and components
into my OpenGL rendered scene.

The problem lies, as I might guess, in 2 points:

1.)
What one would have to do is to redirect the JPanel.paint() output
into a Graphics object created by a TextureRenderer and use this
texture then in the scene. I guess, the poblem there would be the amount
of data having to be copied around.

2.)
But the much worse problem I guess is handling the mouse events.
I ran tests on how long OpenGL picking (in render mode GL_SELECT) it
takes. The result was that (against what I would have expected) picking
almost takes as long as a usual display in render mode GL_RENDER.
As a consequence, instant picking (what would be required for MouseEntered,
-Exited and MouseMotion events) would slow down everything by a factor 2.

Besides these two major problems, I’m also not so familiar with opengl to know
how to get the coords of the mouse relative to the primitve being hit within the
picking procedure. That means, by selecting and picking, I get information about
which primitve is under my mouse pointer, but not at which position in that primitive
my mouse is.

Uff, lot of text.

Also if you don’t have a solution to my problem, I would appreciate if you could just tell
me your thoughts on this problem.

With best regards,
Oliver

Take a look at the Fusion Framework, linked off the JOGL home page. They’ve integrated Swing and 3D via JOGL. You should contact the authors and see whether they’re willing to open source their project.

I did something similair and passing the correct events to Swing at the right time is a massive task, not to mention threading issues.

Further, you have to efficiently grab the updated regions of the panel. Sending the whole thing to a texture every time will kill performance right away.

In the end it worked, but I spent quite a few hours implementing it.

My solution is too integrated in my API, so it wouldn’t be useful to you