Threads inhibiting events?
So I have a piece of code that reads mousePressed and mouseReleased events. It seems to work fine for the most part. Then I decide I want to make a scroll bar scroll when a particular area is pressed, so I have flags set for if a button is being pressed. That's all good. The problem comes when I start a thread to 'scroll' the scroll bar (right now it just is printing text to say that it would be doing something). My problem is that when I start this thread, it doesn't stop. Ever. I release the mouse and it never sets the flags to false (so the mouseReleased code isn't being called because of the running thread. How do I fix this? Any help is appreciated.
publicvoid mousePressed(MouseEvent arg0)
{
int x = arg0.getX();
if(x<_boxes[1])
{
_flags[0]=true;
}
elseif(x>_boxes[4])
{
_flags[1]=true;
}
System.out.println("Repaint Now");
repaint();
System.out.println("Run Now");
_sc.run();
}
publicvoid mouseReleased(MouseEvent arg0)
{
System.out.println("Stop Now");
_flags[0]=false;
_flags[1]=false;
System.out.println("Repaint Now");
repaint();
}
}
class ScrollFunction
extends Thread
{
publicvoid run()
{
while(true)
{
try
{
System.out.println("Scrollage!");
Thread.sleep(1000);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}

