# Loop not running

**URL:** <https://discourse.processing.org/t/loop-not-running/489>\
**Category:** Coding Questions\
**Created:** [May 29, 2018, 9:41am UTC](https://discourse.processing.org/t/loop-not-running/489 "2018-05-29T09:41:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ag123](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@ag123](https://discourse.processing.org/u/ag123)\
**Post date:** [May 29, 2018, 9:41am UTC](https://discourse.processing.org/t/loop-not-running/489/1 "2018-05-29T09:41:56Z")

</div>

hi i’m starting out with processing  
currently using processing 3.3.3 core. i’m using processing core jar library and doing so in eclipse as described here:  
[https://processing.org/tutorials/eclipse/](https://processing.org/tutorials/eclipse/)

my codes is as follows:

```auto
package org.processing;

import processing.core.PApplet;

public class ProcessingTest extends PApplet {

    final int WIDTH = 800;
    final int HEIGHT = 600;
    
    
    @Override
    public void draw() {
        super.draw();
        ellipse(width/2,height/2,second(),second());
        finished = false;
    }

    @Override
    public void settings() {
        super.settings();
        size(WIDTH, HEIGHT);
    }

    @Override
    public void setup() {
        super.setup();
        colorMode(RGB);
        fill(120,50,240);
    }

    
    public static void main(String[] args) {
        PApplet.main("org.processing.ProcessingTest");

    }

}

```

the trouble is if i remove the statement finished = false; in draw()  
the loop stops running. initially the loop() didn’t run at all until i figured out to place the statement finished = false; in draw()

is this a normal behaviour? is that a bug e.g. that i’d need to update the core etc?

---

<div class="post-metadata">

**Author:** ![ag123](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@ag123](https://discourse.processing.org/u/ag123)\
**Post date:** [May 29, 2018, 11:08am UTC](https://discourse.processing.org/t/loop-not-running/489/2 "2018-05-29T11:08:11Z")

</div>

ok i found the ‘problem’

```auto
public class PApplet implements PConstants {
  public void draw() {
    // if no draw method, then shut things down
    //System.out.println("no draw method, goodbye");
    finished = true;
  }

```

hence, problem is solved by not calling the overridden superclass methods

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [May 29, 2018, 11:48am UTC](https://discourse.processing.org/t/loop-not-running/489/3 "2018-05-29T11:48:14Z")

</div>

You can also remove the statements

```auto
super.settings();
super.setup();
super.draw();

```

as these call empty methods in the PApplet class.

---

<div class="post-metadata">

**Author:** ![ag123](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@ag123](https://discourse.processing.org/u/ag123)\
**Post date:** [May 29, 2018, 11:51am UTC](https://discourse.processing.org/t/loop-not-running/489/4 "2018-05-29T11:51:43Z")

</div>

thanks, i’ve done just that. and as it turns out the superclass super.draw() in PApplet isn’t empty.  
it might be a handy ‘feature’ in the sense that now the sketch can simply exit by setting  
`finished = true;`  
but in structured programming, this should probably be done by calling the superclass methods rather than setting the globals/instance variable that way

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [May 29, 2018, 2:50pm UTC](https://discourse.processing.org/t/loop-not-running/489/5 "2018-05-29T14:50:31Z")

</div>

You are right, the draw() method in PApplet is not empty - it simply stops the sketch looping IF the user has not overridden the method. This is an even more compelling reason for not calling `super.draw()` because the developers may change the contents of the default draw() method so in future it might not do what you expect. In this case I would simply set `finished = true;` although this might also change if it is not a documented part of the API.
