wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes embedding a Processing Applet in SWT (Eclipse RCP), otherwise I'd need a text editor engine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "embedding a Processing Applet in SWT (Eclipse RCP), otherwise I Watch "embedding a Processing Applet in SWT (Eclipse RCP), otherwise I New topic

embedding a Processing Applet in SWT (Eclipse RCP), otherwise I'd need a text editor engine

Felix Woitzel

Joined: May 19, 2010
Posts: 5
I'm having difficulties on more than one level and I hope some Eclipse plugin specialists here can help. Maybe you can also learn something.

First off some motivation: I'm working on a tiny hobby framework for programming Pixelshaders and other scripts with immediate user feedback (pressing enter, see the result). I want to use Processing, which is based on Java Applets, as the media- and rendering-core. For example in a renderer-prototype I use the GLGraphics library for a simple high-level interface to OpenGL, later the Minim library will be used for possible music-visualization. The application which I have on my mind should allow the user to load, save and edit "preset" files, in which some parts will be plain text/code (especially shader language). Ideally the editor would be in a semi-transparent overlay over the renderer output. Unfortunately I have not found any text editor engines for Processing, so I was thinking of embedding the Applet into a component framework: One tab for the renderer, other tabs with the different (code) editors. After successfully embedding a simple sketch into a Swing window (tutorial) I came to the first hurdle: The OpenGL context could not be created like in the context of running it as an applet. Anyway, I spared out this problem and went one step further. If it was possible to run a Processing sketch in Swing, then how about SWT or an Eclipse-based client with a workbench, OSGi architecture, and ready-made code editors.
So I have created a new Plugin project in Eclipse, the basic rich client with a perspective and a view. I have also already found out how to embed Swing in SWT, which is working fine for 'hello world' labels, but:

No matter where I try to instantiate and initialize the Processing sketch class in the Eclipse-based application (may it be directly in the View class, or even in the Activator class) I get a full bunch of internally handled Eclipse exceptions. The applet doesn't even use OpenGL yet and it can be embedded in a Swing window without problems. Moreover the applet is not added to the GUI so far, the troubling line of code is a simple DummySketch sketch = new DummySketch(); sketch.init(); (where the init method starts the Processing-specific threads)

I guess it's only flicking the right switch at the right location but I'm clueless. Simply calling the init method from a new thread didn't work and I didn't find the answer in the first 15 minutes of searching, so I hoped I can find some help here.
In Swing I'd know how to dispatch an asynchronous call just like

Am I completely wrong or what is the equivalent code in SWT?

happy holidays, Felix

Will code Java for Food: Coffee, Cookies, Milk, Fishies, I'm an omnivore...
Felix Woitzel

Joined: May 19, 2010
Posts: 5
stupid me! interpreting stack traces is of advantage... I didn't place the Processing jar on the classpath description in the plugin.xml and the problem was that PApplet was unknown at runtime

That's it:
I agree. Here's the link: http://aspose.com/file-tools
subject: embedding a Processing Applet in SWT (Eclipse RCP), otherwise I'd need a text editor engine
Similar Threads
JTree and JSpinner (Beginner)
Is Netbeans more complicant than eclipse?
For the Authors: SWT
choosing eclipse
For Eric and Dan: Swing -> SWT