# How to create a custom window

**URL:** https://discourse.processing.org/t/how-to-create-a-custom-window/39254
**Category:** Coding Questions
**Created:** [October 13, 2022, 8:21pm UTC](https://discourse.processing.org/t/how-to-create-a-custom-window/39254 "2022-10-13T20:21:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![5x9x7x2x7x9](https://avatars.discourse-cdn.com/v4/letter/5/9de0a6/32.png) [@5x9x7x2x7x9](https://discourse.processing.org/u/5x9x7x2x7x9)
#### Post date: [October 13, 2022, 8:21pm UTC](https://discourse.processing.org/t/how-to-create-a-custom-window/39254/1 "2022-10-13T20:21:38Z")

</div>

Hello, I’ve been wondering how you could create a second window

You have the main window which shows the game  
and then you have the second window with buttons you can press to move the character and do actions

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [October 13, 2022, 9:02pm UTC](https://discourse.processing.org/t/how-to-create-a-custom-window/39254/2 "2022-10-13T21:02:53Z")

</div>

One option would be to create a default Processing window as the main window and use a subclassed PApplet as the second window:

```auto
import controlP5.*;

ControlP5 cp5;
GraphicWindow wnd;
float radius = 50;

void slider(float value){
  radius = value;
}

void setup() {
  size(400,400);
  surface.setTitle("Default Window");
  background(209);

  cp5 = new ControlP5(this);
  cp5.addSlider("slider")
     .setPosition(width/2 - 150, 100)
     .setSize(300,24)
     .setRange(0, 500)
     .setValue(150)
     .setLabelVisible(false)
     .setColorBackground(color(255, 255, 255))
     .setColorForeground(color(180,180,180))
     .setColorActive(color(180,180,180));
     ;
     wnd = new GraphicWindow();
}

void draw() {
  
}
 
class GraphicWindow extends PApplet {

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

  void settings() {
    size(600, 600);
  }

  void setup() {
    background(150);
  }

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

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

```

---

<div class="post-metadata">

### Author: ![5x9x7x2x7x9](https://avatars.discourse-cdn.com/v4/letter/5/9de0a6/32.png) [@5x9x7x2x7x9](https://discourse.processing.org/u/5x9x7x2x7x9)
#### Post date: [October 13, 2022, 9:58pm UTC](https://discourse.processing.org/t/how-to-create-a-custom-window/39254/3 "2022-10-13T21:58:06Z")

</div>

This works very well, thank you
