Is it possible to add a Xith canvas to a component of an existing Swing/AWT/SWT application?
I’ve seen that there is the UIWindow stuff, but what I need is the opposite.
If I understand, you have the Canvas3D that is part of core xith. The Canvas3D uses a CanvasPeer from the particular OpenGL bridge used.
I am particularly interested in using xith within an SWT application. There is an ongoing effort to create an SWT OpenGL bridge. How difficult would it be to write a port of xith to this bridge?
If I understood right, this should show you how it is done.
As you can see, to embed my canvas into my JFrame, I submit parentFrame.getContentPane() as the canvas’s parent.
Thanks, that’s what I meant.
For SWT the options I now have are:
- Wait SWT_AWT support for linux
- Port Xith3D to SWT OpenGL bridge
I’ll report here if I make some progress, in case someone is interested in writing an eclipse plugin that uses xith…
Interesting, everyone is using SWT and OpenGL at the same time.
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=LWJGL;action=display;num=1071683401
In the very recent versions of SWT, using the function
org.eclipse.swt.awt.SWT_AWT.new_Frame()
will return a java.awt.Frame
then you should be able to add Swing components, and I do not see why not a Xith3D canvas!
For example, look at this code snippet http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/snippits/snippet135.html, where a JTable is embedded in an SWT gui.
This used to work only on Windows, but the class SWT_AWT was moved up outside of a win32 package and I think it will work on Linux now.
They said they will only be able to support linux when jdk1.5 comes out, or at least the first betas.
/me wonders what’s swt ???
SWT (Standard Widget Toolkit) is part of the Eclipse project and ahem something like AWT/Swing.
Where do I go to actually see the differences listed between SWT and AWT? I’ve always considered SWT a useless project… since Swing works fine (hasn’t been “slow” for years now), but I understand that SWT uses “native” widgets where possible, so it seems to compare to AWT.
I am not very literate about SWT, but from what I understands it has a more orthogonal design that AWT/Swing. Overall, Eclipse code/APIs are very clean and well designed.
Apart from this, I don’t see either the utility of SWT…
Another advantage of SWT is that GCJ supposedly works with it. (Has anyone actually tried this?)
It may be desirable to actually use Java in a slightly different way and actually create executables that are seperate from the virtual machine.
It would be VERY cool to be able to do the same with xith3d/jogl and create an application separate from the JVM.
This would not be possible with AWT/Swing (yet?).
This is somewhat interesting and related:
I’m trying to imbed a canvas into a JPanel. So I have class MyJPanel derived from JPanel. MyJPanel contains another JPanel which is where I want the canvas. I don’t get any errors, the rendering loop runs but I never see anything. I have set up the universe to have nothing in it, I just want to see a black square, but I don’t.
Anyone have any ideas?
I get exactly what I want if I let Xith3D create the window by passing null to the first argument of renderPeer.makeCanvas().
panel = new JPanel();
renderPeer = new RenderPeerImpl();
canvasPeer = renderPeer.makeCanvas(panel,panel.getWidth(),panel.getHeight(),bits,false);
canvas = new Canvas3D();
canvas.set3DPeer(canvasPeer);
Enumeration e = universe.getViews();
for(int loop=0;loop<viewIndex-1;loop++)
universe.getViews().nextElement();
view = (View)universe.getViews().nextElement();
if(view!=null)
view.addCanvas3D(canvas);
add(panel);
edit: well I got part of it, I wasn’t setting the panel size
edit: IGNORE this post, I think I’ve got it.
[quote]Another advantage of SWT is that GCJ supposedly works with it. (Has anyone actually tried this?)
[/quote]
I didn’t try myself but I saw that eclipse has been compiled for linux using GCJ.
I heard it compiles using gcj, kaffe and more free VMs. Linux and especially Debian (and Debian-based distros like Knoppix) need Opensource-Toolchains. Java being completely Open-Source is a nice dream and would lead to a breakthrough.