# Moving line markers in a GUI

**URL:** <https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489>\
**Category:** Coding Questions\
**Created:** [March 20, 2019, 5:49pm UTC](https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489 "2019-03-20T17:49:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iampadik](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@iampadik](https://discourse.processing.org/u/iampadik)\
**Post date:** [March 20, 2019, 5:49pm UTC](https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489/1 "2019-03-20T17:49:14Z")

</div>

![GUI_screenshot_for_forum](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/90afec740a4baa0bcf83195c7b04f42da66ce795.png)

Hi all. So, this is a GUI I have made using Processing 3.5.3 in Windows7 (64 bit). I have an issue with having a continuously moving marker along with the mouse in the rectangle where I see the data. Currently, I have written the code such that I get a static black vertical line only at the places I click (as shown in the attached image) and otherwise I don’t see any vertical line as I move the mouse.

In order to achieve this target, I am trying the following: On clicking “marker” button, I call for a thread in which the data plotting rectangle refreshes itself (Let’s ignore plotting of data for now) and as I move the mouse, the vertical line moves. It does refresh & the vertical line moves with mouse. But there are rectangles created randomly in the vicinity. I don’t know why is this happening. Probably, moving mouse interrupts… But, how do I handle them efficiently. I tried looking for any marker facility in G4P library. Couldn’t find any. Any suggestions?? Following is the thread code (being called after I click “Marker” buttton). Also the image is provided to show the problem:

```auto
void marker()
      {
        
        
       while(true) {
        
        if((mouseX<950) && (mouseX>150) && (mouseY<600) && (mouseY>50))
                       {
                        //background(255);
                        //redraw();
                        displayframe();
                         println(mouseY);
                         stroke(0);
                         strokeWeight(1.2);
                        //fill(0);
                        line(mouseX,50,mouseX,600);
                        //line(150,mouseY,950,mouseY);
                       }
                   }

void displayframe()
       {
         fill(255);
         rect(150,50,800,550);
         //println("ho, hotay");
       }

}

```

 ![GUI_gonewrong_screenshot_for_forum](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1fe97ab45baba73b7c897d1e1d67931b30947a85.png)

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [March 21, 2019, 5:51am UTC](https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489/2 "2019-03-21T05:51:08Z")

</div>

The information you provided is not enough to resolve your issue. However, one thing I would like to suggest is to remove the `while()`. This is very likely not the best approach for what you are trying to do and it should not be used inisde your `draw()` function.

Please also go back to your post, edit your post, select your code in the post, and click in the `</>` button to format your text as code. Don’t forget to save your post to save the changes.

Kf

---

<div class="post-metadata">

**Author:** ![iampadik](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@iampadik](https://discourse.processing.org/u/iampadik)\
**Post date:** [March 21, 2019, 10:52am UTC](https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489/3 "2019-03-21T10:52:04Z")

</div>

@kfrajer,

Well thanks for whatever suggestions you could give. I am trying to find the solution on my own as of now. Would like to know what information do you seek that will help you find a way to solve the issue. Worst case, I will avoid refreshing this thing. Instead convert the “arrow” mouse cursor into a “plus” cursor.

Thanks.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [March 21, 2019, 4:29pm UTC](https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489/4 "2019-03-21T16:29:04Z")

</div>

In your case, you need to present a [MCVE](https://stackoverflow.com/help/mcve). The code you provided is not enough to see your issue.

Kf

---

<div class="post-metadata">

**Author:** ![iampadik](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@iampadik](https://discourse.processing.org/u/iampadik)\
**Post date:** [March 21, 2019, 4:56pm UTC](https://discourse.processing.org/t/moving-line-markers-in-a-gui/9489/5 "2019-03-21T16:56:19Z")

</div>

Okay. I understand. This code is so huge (you could as well call it a noob code) that it looks like it will take sometime to provide a MCVE (disadvantages of not being a coder). I will try to follow the instructions and come up with something re-presentable.

Thanks for your time.

Iampadik
