How to open multiple windows?

When you’re messing around for fun or something, I’m able to make the window move or resize if I want to. Is there a way to open multiple windows with the same code?

There are several ways to do this; here’s one:

import javax.swing.*;

void setup() {
  size(800,800);
  surface.setTitle("Default Window");
  
  JFrame wnd1 = new JFrame("Window One");
  wnd1.setUndecorated(true);
  wnd1.setBounds(100,100,300,350);
  wnd1.setVisible(true); 
  
  JFrame wnd2 = new JFrame("Window Two");
  wnd2.setBounds(300,200,300,350);
  wnd2.setVisible(true); 
  
  JFrame wnd3 = new JFrame("Window Three");
  wnd3.setBounds(500,300,300,350);
  wnd3.setVisible(true); 
  
}

void draw(){
  // Use default canvas from default wnd if you need this for graphics
  fill(255,0,0);
  circle(width/2, height/2,300);
}

Can also use PApplets.

2 Likes

Do a search in the forum for multiple windows.
You can decide which best suits your needs.

image

:)

I just discovered this myself earlier today. Serendipitous!

From the Processing IDE:
File > Examples > Tests > MultipleWindows

As svan said, this approach uses PApplets.