How can I remove the exit button in a processing programs frame?

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.

    void setup()
    {
      size(200, 200);
      frame.removeNotify();
      frame.setUndecorated(true);
      frame.addNotify();
    }
    
  • edited February 2014

    That works for Java2D only. For the OPENGL based engines too:

    /** 
     * setUndecorated (v4.41)
     * by  rbrauer (2013/Jul)
     * mod GoToLoop (2013/Dec)
     * 
     * forum.processing.org/one/topic/
     * setundecorated-conflic-with-loadlont
     *
     * forum.processing.org/two/discussion/2018/
     * remove-decoration-window-under-p3d
     */
    
    void setup() {
      size(400, 320, removeFrameBorder(P3D));
    
      frameRate(60);
      smooth(8);
      stroke(#00FFFF);
      strokeWeight(1.5);
      textSize(32);
    }
    
    void draw() {
      background(0300);
    
      fill(#FF0000);
      text(frameCount, width - 100, 40);
    
      fill(#0000FF);
      translate(frameCount % width, height >> 1);
      sphere(0150);
    }
    
    String removeFrameBorder(String gfx) {
      if (!isGL()) {
        frame.removeNotify();
        frame.setUndecorated(true);
        frame.addNotify();
      }
    
      return gfx;
    }
    
  • @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).

  • edited February 2014

    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. :)

  • Answer ✓

    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! :))

Sign In or Register to comment.