I’m trying to set the present background colour of a sketch’s second window launched through PApplet.runSketch()
, however nothing I’ve tried works. I don’t want to set processing’s background preference for all sketches. Below is my code with comments of what I’ve tried so far - most of it is ignored without errors.
Can anybody see what I’m doing wrong or know of an alternative solution? Thanks in advance.
//new window instance
Main win;
public void settings()
{
size(320, 240);
}
void setup()
{
surface.setLocation(20, 30);
surface.setTitle("Menu");
//** fourth attempt at setting present background colour, just in case it
//affects the child window but it seems to be ignored
//frame.setBackground(new Color(255, 0, 0));
//create new window
win = new Main();
}
void draw()
{
background(100, 100, 100);
}
class Main extends PApplet
{
Main()
{
//** first attempt at setting present background colour, all flags work but bgcolor does nothing.
PApplet.runSketch(new String[] {"--present", "--hide-stop", "--bgcolor=#ff0000", "--display=1", this.getClass().getSimpleName()}, this);
}
void settings()
{
size(800, 600);
}
void setup()
{
//** second attempt at setting present background colour, both are ignored.
//frame.setBackground(new java.awt.Color(255, 0, 0));
//frame.setBackground(new Color(255, 0, 0));
//** third attempt at setting present background colour, these create errors.
//((JFrame) frame).getContentPane().setBackground(Color.BLACK);
//frame.getContentPane().setBackground(new Color(255, 0, 0));
surface.setTitle("Main");
background(0, 0, 0);
}
void draw()
{
rect(random(width), random(height), random(50), random(50));
}
void exit()
{
//dispose of this class, set window to invisible and win to null
dispose();
surface.setVisible(false);
win = null;
}
}