Moving line markers in a GUI

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:

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");
       }


}

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

@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.

In your case, you need to present a MCVE. The code you provided is not enough to see your issue.

Kf

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