Creating simple GUI to change variables in script

The source code below will allow you to create two windows controlled by a single sketch: a default Processing window for your controls and a PApplet window that could be used for graphics. Pulling the slider in the default window will change the size of the circle in the graphic window.

import controlP5.*;

ControlP5 cp5;

int radius = 50;
GraphicWindow wnd;

void setup() {
  size(400, 250);
  surface.setTitle("Default Window");
  cp5 = new ControlP5(this);
  cp5.addSlider("radius")
    .setPosition(100, 50)
    .setSize(200, 20)
    .setRange(5, 255)
    ;
  wnd = new GraphicWindow();
}

void draw() {
}

void mousePressed() {
  println("mousePressed in default window");
}

class GraphicWindow extends PApplet {

  public GraphicWindow() {
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  }

  void settings() { // Necessary for PApplet
    size(300, 300);
  }

  void setup() {
  }

  void draw() {
    background(150);
    fill(0, 255, 0);
    circle(width/2, height/2, radius);
  }

  void mousePressed() {
    println("mousePressed in graphic window");
  }
}