We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Embedding opengl papplet in a Frame
Page Index Toggle Pages: 1
Embedding opengl papplet in a Frame (Read 869 times)
Embedding opengl papplet in a Frame
Apr 10th, 2008, 7:56pm
 
Hi,

I'm trying to embed an opengl PApplet in a Frame but I'm getting this error:
---
D:\jorge\Java\saverbeans-sdk-0.2>java -classpath core.jar;opengl.jar;jogl.jar;.
Test
java.lang.NoSuchMethodError: processing.core.PGraphics3D: method <init>()V not f
ound
       at processing.opengl.PGraphicsOpenGL.<init>(PGraphicsOpenGL.java:103)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at processing.core.PApplet.createGraphics(PApplet.java:1113)
       at processing.core.PApplet.size(PApplet.java:897)
       at processing.core.PApplet.size(PApplet.java:838)
       at DesafioTexturaDinamica.setup(DesafioTexturaDinamica.java:13)
       at processing.core.PApplet.handleDisplay(PApplet.java:1285)
       at processing.core.PGraphics.requestDisplay(PGraphics.java:680)
       at processing.core.PApplet.run(PApplet.java:1454)
       at java.lang.Thread.run(Unknown Source)
Error while running applet.
java.lang.RuntimeException: processing.core.PGraphics3D: method <init>()V not fo
und
       at processing.core.PApplet.createGraphics(PApplet.java:1130)
       at processing.core.PApplet.size(PApplet.java:897)
       at processing.core.PApplet.size(PApplet.java:838)
       at DesafioTexturaDinamica.setup(DesafioTexturaDinamica.java:13)
       at processing.core.PApplet.handleDisplay(PApplet.java:1285)
       at processing.core.PGraphics.requestDisplay(PGraphics.java:680)
       at processing.core.PApplet.run(PApplet.java:1454)
       at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: processing.core.PGraphics3D: method <init>()V not fo
und
       at processing.core.PApplet.createGraphics(PApplet.java:1130)
       at processing.core.PApplet.size(PApplet.java:897)
       at processing.core.PApplet.size(PApplet.java:838)
       at DesafioTexturaDinamica.setup(DesafioTexturaDinamica.java:13)
       at processing.core.PApplet.handleDisplay(PApplet.java:1285)
       at processing.core.PGraphics.requestDisplay(PGraphics.java:680)
       at processing.core.PApplet.run(PApplet.java:1454)
       at java.lang.Thread.run(Unknown Source)

D:\jorge\Java\saverbeans-sdk-0.2>
---
My code is this:
Code:

import java.awt.Color;
import java.awt.Component;
import java.awt.*;
import java.awt.Graphics;
import java.awt.Point;
import java.util.Properties;
import java.util.logging.*;
import java.io.*;

import processing.core.*;
import processing.opengl.*;
import java.net.*;

public class Test extends Frame {

public Test() {
super("Embedded PApplet");

setLayout(new BorderLayout());
PApplet applet;
try {
URL u[] = {new URL("file", null, "DesafioTexturaDinamica.jar")};
URLClassLoader ucl = new URLClassLoader(u);
Class cl = ucl.loadClass("DesafioTexturaDinamica");
applet = (PApplet) cl.newInstance();
applet.init();
applet.size(320, 300);
add(applet, BorderLayout.CENTER);
} catch (ClassNotFoundException cnfe) {
System.out.println("Classnotfound" + cnfe.getMessage());
} catch (InstantiationException ie) {
System.out.println("InstantiationException" + ie.getMessage());
} catch (IllegalAccessException iae) {
System.out.println("IllegalAccessException"+iae.getMessage());
} catch (Exception e) {
System.out.println("Exception"+e.getMessage());
}
}

public static void main(String args[]) {
Test t = new Test();
t.setSize(new Dimension(800, 600));
t.show();
}
}



Does anybody know what I'm missing here?

thanks,
jorge
Re: Embedding opengl papplet in a Frame
Reply #1 - Apr 10th, 2008, 8:03pm
 
I think you need to call the main() function of the PApplet first.

See http://processing.org/reference/environment/export.html
Re: Embedding opengl papplet in a Frame
Reply #2 - Apr 10th, 2008, 8:17pm
 
I think calling main() will launch the applet as an application. That's not exactly what I'm trying to do, but I tried it anyway and the problem remains...
Re: Embedding opengl papplet in a Frame
Reply #3 - Apr 11th, 2008, 7:34pm
 
From the look of the error, you're not setting up the ClassLoader correctly. You don't need a ClassLoader to start a Processing sketch, so you shouldn't bother. Check out the code for PApplet.main() to see how a new frame is created and a named sketch is added to it. Basically the ClassLoader doesn't seem to know where to find the right files from core.jar.
Page Index Toggle Pages: 1