# Is there a way to prevent Processing from opening a graphics window?

**URL:** <https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388>\
**Category:** Coding Questions\
**Created:** [December 31, 2022, 5:05pm UTC](https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388 "2022-12-31T17:05:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrinalino](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@adrinalino](https://discourse.processing.org/u/adrinalino)\
**Post date:** [December 31, 2022, 5:05pm UTC](https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388/1 "2022-12-31T17:05:33Z")

</div>

Hi there. I would like to write a program that only has text output. Is there a way to prevent processing from opening a graphics window?  
Thanks for your help.  
Cheers, Adrian.

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [December 31, 2022, 5:43pm UTC](https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388/2 "2022-12-31T17:43:35Z")

</div>

Yes there is!  
While it is possible to hide the window you can prevent it from opening in the first place! This would be an example:  
NONERenderer.java

```auto
import processing.core.*;
public class NONERenderer extends processing.core.PGraphics {
  public PApplet instance;
  public NONERenderer() {
  }
  @Override
    public void setParent(PApplet p) {
      instance=p;
  }
  @Override
    public void setPrimary(boolean b) {
  }
  @Override
    public PSurface createSurface() {
      return new EmptySurface(this);
  }
  class EmptySurface extends PSurfaceNone{
    EmptySurface(PGraphics pg){
      super(pg);
    }
    @Override
    public void initFrame(PApplet sketch){
      initOffscreen(sketch);
    }
  }
}

```

MainSketch.pde

```auto

void setup() {
  size(100, 100, "NONERenderer");
}
void draw() {
  println("text");
  exit();
}

```

What this code does is creating a renderer that simmply doesn’t open a window. It is also ill-adviced to try and use graphics-commands on this as there is no window.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [December 31, 2022, 6:01pm UTC](https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388/3 "2022-12-31T18:01:16Z")

</div>

Another option is to just not show the window (may see flash):

```auto
void setup(){
    surface.setVisible(false);
}

```

---

<div class="post-metadata">

**Author:** ![adrinalino](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@adrinalino](https://discourse.processing.org/u/adrinalino)\
**Post date:** [January 1, 2023, 1:56pm UTC](https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388/4 "2023-01-01T13:56:47Z")

</div>

Great, It works flawlessly.  
Thanks guys!  
Cheers,  
Adrian.

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [January 1, 2023, 2:33pm UTC](https://discourse.processing.org/t/is-there-a-way-to-prevent-processing-from-opening-a-graphics-window/40388/5 "2023-01-01T14:33:19Z")

</div>

This is what i use when crunching numbers, sometimes when you push escape to close the window and it doesn’t work until you click, use surface.setVisible(true) and it works every time
