confirm dialog on separate thread
in
Programming Questions
•
1 year ago
I want a confirm dialog, but it's important that draw keeps running.
I had a confirm dialog working but it paused draw, now i placed it in a separate thread but i don't see the dialog anymore.
Also i'm not sure about:
closeFrame = closePane.getFrameForComponent(p);
In draw i used 'this', but if i used 'this' in the CloseThread (bad name btw) class then i got a error.
Getting the Frame is important for me since i need to get the position.
- import javax.swing.JOptionPane;
- import java.awt.Point;
- CloseThread closeThread;
- void setup() {
- }
- void draw() {
- background(0);
- text(frameCount, 20, 20);
- }
- void keyPressed() {
- if (key == ESC) {
- key = 0;
- closeThread = new CloseThread(this);
- println("close");
- }
- }
- class CloseThread extends Thread {
- PApplet p;
- JOptionPane closePane;
- Frame closeFrame;
- int response;
- CloseThread(PApplet p) {
- }
- void start () {
- super.start();
- if (response != 1) {
- response = closePane.showConfirmDialog(null, "Are you sure you want to quit?");
- }
- closeFrame = closePane.getFrameForComponent(p);
- Point closeLoc = closeFrame.getLocation();
- println(response);
- println(closeLoc.x);
- }
- void run () {
- }
- void quit() {
- interrupt();
- }
- }
1