A simple question: Is it possible to view gui of java Swing library and lwjgl 3D scene in the same window without using any additional gui libraries? How?
Asked
Active
Viewed 3,143 times
2
-
Can you please clarify: what exactly is a "java default gui"? – Hovercraft Full Of Eels Jul 04 '12 at 19:47
-
well java has a gui that you can use wthout any libraries. Am i calling it wrong? – Qualphey Jul 04 '12 at 19:48
-
gui - graphical user interface – Qualphey Jul 04 '12 at 19:49
-
Yeah, I think I know what "GUI" means. Are you referring to a Swing GUI or AWT GUI? Both are libraries that are part of core Java and can be used to create GUI's. – Hovercraft Full Of Eels Jul 04 '12 at 19:49
-
Java has built-in libraries to create GUIs- `Swing` and `AWT` – David B Jul 04 '12 at 19:49
-
If the lwjgl 3D scene can be made into an image of some sort, say a jpg or png image, then either AWT or Swing can display it. – Hovercraft Full Of Eels Jul 04 '12 at 19:50
-
Or if it can be made into an array of ints that hold the RGBA bytes (for red, green, blue, and alpha composite), then this can be displayed as well. – Hovercraft Full Of Eels Jul 04 '12 at 19:54
-
@HovercraftFullOfEels you can write a full anwser about that. – Qualphey Jul 04 '12 at 19:55
-
I would, but I know nothing about the lwjgl libraries, and so I don't know if 3d images can be converted to the rgba ints. – Hovercraft Full Of Eels Jul 04 '12 at 19:57
-
@HovercraftFullOfEels look at this http://www.lwjgl.org/javadoc/org/lwjgl/opengl/Display.html#setParent(java.awt.Canvas) – Qualphey Jul 04 '12 at 20:28
-
I don't see how one can get the image from the Display other than with a Robot object -- now that will work. – Hovercraft Full Of Eels Jul 04 '12 at 20:41
-
look at the setParent() method – Qualphey Jul 04 '12 at 22:25
1 Answers
3
You can use the method Display.setParent(java.awt.Canvas) to put the LWJGL display on a canvas. You can then incorporate this canvas into your Swing GUI. Please note that there may be slight performance issues with said approach.

Oskar
- 1,321
- 9
- 19