no display window --- noSize()???

edited April 2015 in How To...

I started using processing and got used to a lot of the functions. While it might be easier to go to another language, I would prefer to continue using my own code and export an image file that I can access at my own convenience. Though, I do not want to see the display window, which is defaulted to size(100,100), every time I run the code.

Can the default display window be prevented? Can I have noWindow please??

Answers

  • edited April 2015 Answer ✓

    There's this little hidden (not really) gem inside Processing, which can affect how the default window looks:

    boolean hidden = false;
    
    void setup() {
    }
    
    void draw() {
      if(!hidden) {
        frame.setVisible(false); //This is what you're looking for.
        hidden = true;
      }
    }
    

    I don't remember or know if there's a way to put frame.setVisible(false) into setup(), but I'm sure this'll do.

  • Beautiful!!!! Thanks for the direction! The 'frame' class was the key that I was not aware of. It holds a treasure chest.

    I used frame.setExtendedState(int) int = 1 and the window started as an icon. (At least it was not right on top of what I wanted to see). I am going to continue looking into the class.

  • Maybe the settings are OS dependent. Most that I've seen points toward .setVisible(false). Yet, on Ubuntu, it does not seem to be the correct command.

  • The only was I see setVisible(false) not working is a window manager which doesn't allow such manipulation after the window was made (EWMH incompliant).

    Which version of Ubuntu do you have? Because the above code works for me on Ubuntu 14.04.

  • I'm on 14.04 too.

    Oddly, the code, exactly as you have it written in your first response, produces a 100x100 box inside a window.

  • edited April 2015

    Then the window is probably affected by fixes and packages I have installed (or those that I don't have installed), that you don't. At this point, there's really nothing you can do in Processing. There's no

    You could try to update packages related to the window manager, such as Compiz (sudo apt-get install compiz). That is probably your best bet, as packages are likely the only thing differing between your system and mine.

  • I'd like to leave this alone, but I can't. Calling 'this' versus 'frame' gets me closer. While the graphic is gone, the window still exists.

    setVisible_this setVisible_frame

  • edited April 2015

    this.setVisible(false) hides the PApplet inside the window, rather than the window itself.

    Do you happen to be using some kind of dark theme? Because the buttons on my screen look like this:

    Screenshot from 2015-04-25 09:02:59

    If you're not, that may indicate something...

  • I am using a theme. Do you think that could have an impact on the setVisible result?

  • edited April 2015 Answer ✓

    No. I thought a different window manager might have an effect.

    import javax.swing.*;
    
    void setup() {
      JFrame frame = new JFrame();
      frame.setSize(200, 200);
      //frame.setVisible(true); //You should see a 2nd window if you uncomment this line.
    }
    

    What does the above code do for you? Do two windows pop up? Or is there only one window appear, like the code intended to?

  • So, I tried the frame.setVisible(false) on my MacOS and it worked as intended. Looking at the differences and going back to Ubuntu, I found that I had noLoop() at the end of draw(). If I removed the noLoop() or added a line that allowed draw() to loop once and then stop, the window disappeared.

    Thanks for your help.

Sign In or Register to comment.