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 & HelpOther Libraries › ControlP5 applet
Page Index Toggle Pages: 1
ControlP5 applet (Read 1488 times)
ControlP5 applet
May 5th, 2010, 7:34am
 
Hello

Im having trouble getting a sketch with ControlP5 to work as an applet. Everything works fine when running in the Processing environment and everything works fine when I "Export Application" and run it on Linux or Windows.

I read this:
export to applet

since the security regulations for applets are very high and strict, you need to make fields and functions that you control with controlP5 public in your code.


So i did this in my code (honestly I've only been working w/Processing/Java for about a week..)

Code:

import controlP5.*;
public ControlP5 controlP5;

// for the input box
String startDatetimeInputText = "";
public Textfield startDatetimetTextField;

String endDatetimeInputText = "";
public Textfield endDatetimetTextField;

String srcFilterInputText = "";
public Textfield srcFilterTextField;

String dstFilterInputText = "";
public Textfield dstFilterTextField;

public Button submitButton;

public void setup() {
 size(sizeW, sizeH);  
 controlP5 = new ControlP5(this);
 ...
}

public void draw() {
...
}


It's certainly possible that I misunderstood the above directions and did something incorrectly...

But  I'm not sure this is the issue because when I run the applet in IE the Java Console says:

Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: controlP5/ControlP5
     at processing_test.setup(processing_test.java:127)
     at processing.core.PApplet.handleDraw(Unknown Source)
     at processing.core.PApplet.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: controlP5.ControlP5
     at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     ... 4 more

The offending line (processing_test.java:127) is:
public void setup() {

 size(sizeW, sizeH);

 controlP5 = new ControlP5(this);

In the above Java Console message does NoClassDefFoundError mean that it can't find the ControlP5 classes? There is a controlP5.jar file in my applet folder

Could someone please help me figure out what I'm missing?

Thanks
Heath


Re: ControlP5 applet
Reply #1 - May 6th, 2010, 6:38am
 
In Processing the setup and draw methods are not be declared public.
Code:
void setup(){
 ...
}

void draw(){
 ...
}

is the way to do it.


Re: ControlP5 applet
Reply #2 - May 10th, 2010, 8:40am
 
Ok, thanks, i made the changes that you suggested.

Any idea why I would still receive the following error in the Java Console?

Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: controlP5/ControlP5
    at processing_test.setup(processing_test.java:127)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: controlP5.ControlP5
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

Thanks
Page Index Toggle Pages: 1