Hi all,
I'm sure this is a simple Java question, but it's eluding me so I thought I'd post here:
I'm trying to add a Text Area to a 2nd "console" window for a current Processing app. I have it working fine when it's added to the main display window (simple example below):
Code:
// add text area to display window
Panel inputPanel;
TextArea textarea;
void setup(){
size(320, 110);
background(50);
inputPanel = new Panel();
inputPanel.setLayout(new BorderLayout());
add(inputPanel);
inputPanel.setBounds(5, 5, 310, 100); // left x, top y, width, height
textarea = new TextArea("");
// A border layout lays out a container, arranging and resizing its components to fit in five regions:
// Each region is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER.
inputPanel.add(textarea, BorderLayout.CENTER);
setLayout(new BorderLayout());
}
void draw() {
}
But I can't get it to work in the 2nd window. See below:
Code:
// attempting to draw text area in 2nd window
UIWindow uiWindow;
PFont font; // must load a font for TextButton class
void setup() {
uiWindow = new UIWindow(320, 110, 15,"Console"); // width, height, framerate, font name, window name
background(0);
size(320, 240);
frameRate(60); // framerate for main window
}
void draw() { // add stuff here to draw to main window
background(0);
}
public class UIWindow extends PApplet { // class for 2nd window
Frame frame;
int width;
int height;
int fps;
String windowName;
Panel inputPanel;
TextArea textarea;
UIWindow (int w, int h, int framerate, String name) {
width = w;
height = h;
fps = framerate;
windowName = name;
frame = new Frame();
frame.setBounds(0, 0, width, height);
frame.setLocation(0, 0);
frame.setResizable(false); // set to true to change window size
frame.add(this);
this.init();
frame.show();
}
void setup() {
size(width, height, P2D);
frameRate(fps); // framerate for 2nd window
frame.setTitle(windowName);
//noLoop();
inputPanel = new Panel();
inputPanel.setLayout(new BorderLayout());
add(inputPanel);
inputPanel.setBounds(5, 5, 310, 100); // left x, top y, width, height
textarea = new TextArea("");
// A border layout lays out a container, arranging and resizing its components to fit in five regions:
// Each region is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER.
inputPanel.add(textarea, BorderLayout.CENTER);
setLayout(new BorderLayout());
}
void draw() { // add stuff here to draw to 2nd window
// draw stuff in console window
}
}
Can anyone help. I'm not interested in using the controlP5 library for this - would rather figure this out. Thanks for the help!
best,
Zachary