# Display trouble

**URL:** <https://discourse.processing.org/t/display-trouble/23777>\
**Category:** Processing\
**Created:** [September 10, 2020, 2:32pm UTC](https://discourse.processing.org/t/display-trouble/23777 "2020-09-10T14:32:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [September 10, 2020, 2:32pm UTC](https://discourse.processing.org/t/display-trouble/23777/1 "2020-09-10T14:32:24Z")

</div>

I’m rather new at Processing. It is different from the programing that I’m used to. I’m an old timer that found Arduino and Processing as something to do during retirement. Anyway, I wrote a short routine that should display a line then erase it and move it over a little. For some reason, sometimes the display window will show nothing, sometimes I’ll get the initial line then the last line, but never what I expect. There must be some kind of way to make the display refresh? Thanks Mike  
\<  
void setup(){  
size(600,600);  
}

void draw(){  
for (int i = 100; i\<400; i=i+1){  
line(i,200,300,400);  
background(255);  
delay(10);  
}  
}  
/\>

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [September 10, 2020, 4:01pm UTC](https://discourse.processing.org/t/display-trouble/23777/2 "2020-09-10T16:01:38Z")

</div>

Hi @mike_z

So, there a few things to know.

1. The draw() method is a loop that refreshes automatically your sketch window. So, you don’t need the for loop only the incrementing position of your line.
2. Processing draws objects in order of appearance, i.e., the background should be called first, and then all the objects that you wish to appear.
3. If you call the background only once in setup, the sketch will keep all objects (in your case all lines being drawn, here is an example:

```auto
int i = 0;
void setup(){
size(600,600);
background(255);
}

void draw(){
i++;
fill(0);
line(100,i,400,i);
}

```

So if you want the line to be refreshed, then you refresh the background at all frames, i.e., call it inside draw(), like this:

```auto

int i = 0;
void setup(){
size(600,600);
background(255);
}

void draw(){
background(255);

i++;
fill(0);
line(100,i,400,i);
}

```

I suggest to you some tutorials on processing that may help you in the future 🙂

> **Helpful links**
>
> The coding train channel:  
> [https://www.youtube.com/watch?v=2VLaIr5Ckbs&list=PLzJbM9-DyOZyMZzVda3HaWviHqfPiYN7e&ab\_channel=TheCodingTrain](https://www.youtube.com/watch?v=2VLaIr5Ckbs&list=PLzJbM9-DyOZyMZzVda3HaWviHqfPiYN7e&ab_channel=TheCodingTrain)
> 
> Processing tutorials:  
> [Tutorials / Processing.org](https://processing.org/tutorials/)
> 
> Processing examples:  
> [Examples / Processing.org](https://processing.org/examples/)

Best regards

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [September 10, 2020, 4:14pm UTC](https://discourse.processing.org/t/display-trouble/23777/3 "2020-09-10T16:14:57Z")

</div>

Thanks for the reply. WHile I was gone, I think I figured out that the display doesn’t refresh until the end of the DRAW function. My problem was that I was using a FOR/NEXT loop and the program stayed in that loop and the end of the DRAW was not gotten to until the FOR/NEXT was over. AND I also palyed with the background and found what you are talking about.  
So… what you did was a FOR/NEXT by using the DRAW repeating method. Learn something every day. Thanks
