Two windows in Eclipse

Hi there,

Following the "frame" example from the CP5 library I tried to implement two windows in my Eclipse project. I've managed to get it running but three out of four times I get the following error message which I believe is being caused by this line but I may be wrong.

p.runSketch(new String[] { this.getClass().getName() }, this);

It also gives me this message but I doubt it has anything to do with the error.

The static method runSketch(String[], PApplet) from the type PApplet should be accessed in a static way

Thanks in advance :) Charles

Ps: The sketch runs fine in processing just not in Eclipse

import peasy.PeasyCam;
import processing.core.PApplet;
import processing.core.PConstants;
import processing.core.PImage;

public class MAIN extends PApplet {

  PeasyCam cam;
  ControlFrame cf;

  public static void main(String[] args) {
    PApplet.main("MAIN");
  }

  public void settings() {
    size((int) (1366 * 0.7f), 730, P3D);
  }

  public void setup() {
    colorMode(PConstants.HSB);
    surface.setLocation((int) (1366 * 0.3), 0);
    cf = new ControlFrame(this, (int) (1366 * 0.3), 730, "Controls");
  }

  public void draw() {

    background(Ui.gradient);
    surface.setTitle(nf(frameRate, 2, 2) + " .fps");
  }
}

import controlP5.ControlP5;
import processing.core.PApplet;
import processing.core.PConstants;
import processing.core.PImage;

class ControlFrame extends PApplet {

  int w, h;
  PApplet p;
  static ControlP5 cp5;

  public ControlFrame(PApplet _p, int _w, int _h, String _name) {
    super();
    p = _p;
    w = _w;
    h = _h;
    p.runSketch(new String[] { this.getClass().getName() }, this);
  }

  public void settings() {
    size(w, h);
  }

  public void setup() {
    surface.setLocation(0, 0);
    surface.setTitle("PHEET - Controls | V3.0");
    frameRate(50);
    colorMode(HSB);

    cp5.addToggle("orth").setPosition((int) (width * 0.01), (int) (height * 0.2)).setSize(50, 15).setValue(true)
      .setMode(ControlP5.SWITCH).plugTo(p, "orth");
    ;
  }

  public void draw() {
    background(245);
  }
}

 RunnableTask.run(): A caught exception occured on thread main-Display-.macosx_nil-1-EDT-1: RunnableTask[enqueued true[executed false, flushed false], tTotal 0 ms, tExec 0 ms, tQueue 0 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <18f5617, ec6eb5b>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>]
 java.lang.RuntimeException: Waited 5000ms for: <18f5617, ec6eb5b>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>
 at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
 at jogamp.newt.WindowImpl$SetPositionAction.run(WindowImpl.java:2884)
 at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:450)
 at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2782)
 at jogamp.newt.WindowImpl.setPosition(WindowImpl.java:2911)
 at jogamp.newt.WindowImpl.setTopLevelPosition(WindowImpl.java:2917)
 at com.jogamp.newt.opengl.GLWindow.setTopLevelPosition(GLWindow.java:514)
 at processing.opengl.PSurfaceJOGL$7.run(PSurfaceJOGL.java:767)
 at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:127)
 at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)
 DefaultEDT.run(): Caught exception occured on thread main-Display-.macosx_nil-1-EDT-1: RunnableTask[enqueued false[executed true, flushed false], tTotal 5002 ms, tExec 5002 ms, tQueue 0 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <18f5617, ec6eb5b>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>]
 java.lang.RuntimeException: Waited 5000ms for: <18f5617, ec6eb5b>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>
 at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
 at jogamp.newt.WindowImpl$SetPositionAction.run(WindowImpl.java:2884)
 at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:450)
 at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2782)
 at jogamp.newt.WindowImpl.setPosition(WindowImpl.java:2911)
 at jogamp.newt.WindowImpl.setTopLevelPosition(WindowImpl.java:2917)
 at com.jogamp.newt.opengl.GLWindow.setTopLevelPosition(GLWindow.java:514)
 at processing.opengl.PSurfaceJOGL$7.run(PSurfaceJOGL.java:767)
 at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:127)
 at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)

Answers

  • Try changing line 47 to

    PApplet.runSketch(new String[] { this.getClass().getName() }, this);

    This is the way of invoking a static method.

  • @quark Thanks, the warning message is now gone unfortunately the error message remains :(

  • In the code above you don't appear to have a closing brace } for the class MAIN the one on line 29 will close the draw() method.

  • Apologies I made a mistake whilst simplifying the code, it is now corrected.

  • I have thoroughly reviewed the code once again and it is this line which is throwing the error. It's in the main sketch, line 21; Is there a different way I can call it?

    surface.setLocation((int) (1366 * 0.3), 0);
    
  • @quark I've read other posts and I see you've got experience with running multiple windows, may I also ask where it is best to make the PApplet.runSketch() call.

    I've seen several examples where it is called in either the main class or the secondApplet class, does it matter?

Sign In or Register to comment.