We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my code that only works when I press Esc, not when I click the stop button. When I click the stop button the pop-up box comes up, but the program closes after even if a press NO
public void exit() {
exitOption = JOptionPane.showConfirmDialog(
frame,
"Are you sure you want to exit?",
"Don't leave me!",
JOptionPane.YES_NO_OPTION);
if (exitOption == JOptionPane.YES_OPTION) {
super.exit();
}
else {
exitOption = 0; // get rid of the box
}
}
How can I get this code to work, or just how can I remove the exit button from the frame. The code working would be better but either way if fine. Please help!
Answers
Processing's IDE interfaces w/ the compiled program thru' network. Stop buttons sends an order to kill it!
Probably not what you're after, but this removes the frame decoration in its entirety.
That works for Java2D only. For the OPENGL based engines too:
@GoToLoop, I did not mean the stop button in the IDE! (lol) I mean the exit button in the window frame. I would like to remove it but keep the title bar (this is in windows). If you can't remove it then how can I detect if it is pressed so I can basically not count the press (so the program wont exit even if the exit button in the frame is pressed).
But thanks for info on the OPENGL thing, I didn't know that because I use JAVA2D for most things, might save me another question in the future. :)
Sorry, I dunno how to pull that out! Some possible solutions I've searched online involved instantiating a JFrame. :(
But Processing already got its own stored in frame! We would have to override that whole process to get any chance! X_X
Ok, that is what I found online too, I think I will just remove the whole frame with frame.setUndecorated(true); :-w I can always make my own exit button! :))