- import controlP5.*;
- import com.shigeodayo.pframe.*;
- ControlP5 cp5;
- SecondApplet secondApplet = null;
- PFrame secondFrame = null;
- ControlP5 cp10;
- boolean subwindowOpen = false;
- void setup() {
- size(400, 300);
-
- cp5 = new ControlP5(this);
-
- cp5.addButton("mybutton")
- .setPosition(100, 200)
- .setSize(50, 50)
- ;
- }
- void draw() {
-
- }
- void mybutton() {
- if(!subwindowOpen) {
- secondApplet = new SecondApplet();
- secondFrame = new PFrame(secondApplet, 210, 0);
- subwindowOpen = true;
- }
- }
- private class SecondApplet extends PApplet {
-
- void setup() {
- size(300, 300);
-
- cp10 = new ControlP5(secondApplet);
- cp10.addButton("closeSubWindow")
- .setPosition(50, 50)
- .setSize(50, 50)
- ;
- }
-
- void draw() {
- }
- }
- void closeSubWindow() {
- secondFrame.dispose();
- secondApplet.dispose();
- subwindowOpen = false;
- }
Sorry I forgot to upload my sketch ^^;
I guess I misunderstood the situation.
There is a button in the main window called "mybutton". When it is pressed, another window appears.
I want to close the second window by pressing "closeSubWindow" button, but nothing happens.
If I close the second window by pressing "x" button at the corner, then I can't reopen it because subwindowOpen is true.
It seems the events generated in the second window is not handled.
How can I deal with this??