I am creating a game with processing 3, and I would like to create a program that opens the setting screen (B screen) from the main screen (A screen) in a separate window, closes the B screen, and returns to the A screen after the setting is complete.
However, A screen の B screen was created by referring to the following site, but B screen is finished A A screen is not available.
I looked into various things, but I couldn't solve it, so I read the source code (PApplet.java), but I didn't understand it, so I'm at a loss.
If anyone understands, please let me know.
Thank you for your cooperation.
[Reference site]
Multiple Window Display
http://3846masa.blog.jp/archives/1038375725.html
PApplet.java Source Code
https://github.com/processing/processing/blob/processing-0243-3.0b5/core/src/processing/core/PApplet.java#L1028-L1031
I also look at the site and actually use the improved class.
Add the following three methods to the SecondApplet class and it will work.
void exit(){
dispos();
}
void close() {
surface.setVisible(false);// Required to clear window
dispos(); // Required to exit thread
}
void all_close(){
System.exit(0);
}
When the ✖ button is pressed, exit() defined in the PApplet class is called, and perhaps something close to System.exit(0).Therefore, if exit() is overridden, everything will not disappear even if you close the window with ✖.However, to stop the thread, you need to call dispos().
Also implement the method of closing only the sub-window from the program (if necessary).I said close().By calling it an instance method, you can terminate only the subwindow from the outside.
Originally, I was able to terminate the program by calling exit(), but because of the override, I cannot terminate the program from the sub-window.You can exit the program by retrieving the PApplet of the main window (as parent), calling parent.exit(), or calling System.exit(0), just like that site.
The only answer to this question was the explanation of exit(), but I also introduced a method that might be relevant.
If you apply this, you can also delete the main window and leave only the sub-window.
© 2024 OneMinuteCode. All rights reserved.