sorry, but above i give you the link to a post from quark ( he makes G4P )
when you run that code you get 2 windows ( with 2 option groups )
and see how that can be operated from both windows,
.p.s. i made for you a ready ( optional image ) button code
( also with the idea you want learn processing )
but you ignored and go for G4P buttons AND a 2 windows concept…
is ok, but not expect using such a high-level library is easier…
ONLY A START:
// https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/21
import g4p_controls.*;
GButton btnMakeWindow1,btnMakeWindow2,btnMakeWindow3;
GButton saveW1;
GWindow window1,window2,window3;
GTextField txf1, txf2, txf3; // input text fields for window1 : letter
GLabel lbltxf1,lbltxf2,lbltxf3; // with labels
String W1_input_txf1, W1_input_txf2, W1_input_txf3; // global strings as result from window 1 / ON button click
void setup() {
size(450, 230);
make_main_buttons();
}
void draw() {
background(202, 239, 127);
}
void make_main_buttons() {
int x1=259, y1=40, dy=50, w1=170, h1=50;
btnMakeWindow1 = new GButton(this, x1, y1, w1, h1);
btnMakeWindow1.setIcon("Letter.png", 1, GAlign.EAST, GAlign.MIDDLE, GAlign.MIDDLE);
btnMakeWindow2 = new GButton(this, x1, y1+dy, w1, h1);
btnMakeWindow2.setIcon("Memo.png", 1, GAlign.EAST, GAlign.MIDDLE, GAlign.MIDDLE);
btnMakeWindow3 = new GButton(this, x1, y1+2*dy, w1, h1);
btnMakeWindow3.setIcon("Delete.png", 1, GAlign.EAST, GAlign.MIDDLE, GAlign.MIDDLE);
}
void handleButtonEvents(GButton button, GEvent event) {
if (button == btnMakeWindow1 && event == GEvent.CLICKED) {
createWindow1();
btnMakeWindow1.setEnabled(false);
}
if (button == btnMakeWindow2 && event == GEvent.CLICKED) {
createWindow2();
btnMakeWindow2.setEnabled(false);
}
if (button == btnMakeWindow3 && event == GEvent.CLICKED) {
createWindow3();
btnMakeWindow3.setEnabled(false);
}
}
void createWindow1() {
println("W1 letter ");
window1 = GWindow.getWindow(this, "Window Letter", 70, 160, 500, 300, JAVA2D);
window1.setActionOnClose(G4P.CLOSE_WINDOW);
window1.addData(new MyWinData());
window1.addDrawHandler(this, "windowDraw");
window1.addMouseHandler(this, "windowMouse");
window1.addKeyHandler(this, "windowKey");
make_W1_widgets();
}
void createWindow2() {
println("W2 memo ");
}
void createWindow3() {
println("W3 delete ");
}
void make_W1_widgets() {
int x1=30, dx=200, y1=40, dy=50, w1=170, h1=20;
lbltxf1 = new GLabel(window1, x1, y1, w1, h1);
lbltxf1.setTextAlign(GAlign.LEFT, null);
lbltxf1.setText("T1");
lbltxf2 = new GLabel(window1, x1, y1+dy, w1, h1);
lbltxf2.setTextAlign(GAlign.LEFT, null);
lbltxf2.setText("T2");
lbltxf3 = new GLabel(window1, x1, y1+2*dy, w1, h1);
lbltxf3.setTextAlign(GAlign.LEFT, null);
lbltxf3.setText("T3");
txf1 = new GTextField(window1, x1+dx, y1, w1, h1);
txf1.tag = "txf1";
txf1.setPromptText("Text field 1");
//txf1.setText("t1");
txf2 = new GTextField(window1, x1+dx, y1+dy, w1, h1);
txf2.tag = "txf2";
txf2.setPromptText("Text field 2");
//txf2.setText("t2");
txf3 = new GTextField(window1, x1+dx, y1+2*dy, w1, h1);
txf3.tag = "txf3";
txf3.setPromptText("Text field 3");
//txf3.setText("t3");
saveW1 = new GButton(window1, x1+dx+10, height-h1, 80, 25);
saveW1.setText(" BACK ");
saveW1.addEventHandler(this,"backW1click"); //___ must be this, not window1 !!
}
public void backW1click(GButton button, GEvent event) {
if ( button == saveW1 ) {
println("W1 back button pressed "+event);
W1_input_txf1 = txf1.getText();
W1_input_txf2 = txf2.getText();
W1_input_txf3 = txf3.getText();
println(lbltxf1.getText(), W1_input_txf1,lbltxf2.getText(),W1_input_txf2,lbltxf3.getText(),W1_input_txf3 );
}
}
public void handleTextEvents(GEditableTextControl textcontrol, GEvent event) { /* code */ }
class MyWinData extends GWinData {
int sx, sy, ex, ey;
boolean done;
int col;
}
public void windowMouse(PApplet appc, GWinData data, MouseEvent event) {
MyWinData data2 = (MyWinData)data;
switch(event.getAction()) {
case MouseEvent.PRESS:
break;
case MouseEvent.RELEASE:
break;
case MouseEvent.DRAG:
break;
}
}
public void windowDraw(PApplet appc, GWinData data) {
MyWinData data2 = (MyWinData)data;
appc.background(200,200,0); // winX background
}
public void windowKey(PApplet appc, GWinData data, KeyEvent keyevent ) {
MyWinData data2 = (MyWinData)data;
}