Click to See Complete Forum and Search --> : how to restart dead thread


retesh_gondal
10-01-2004, 12:09 PM
i am making a scrolling text applet...i have implemented 1 thread ..now on mouse over of text i want to stop scroll which i am able to do now the momemt i exit text scrolling should start again which not happening.

in run() method i hve put a boolean "stopflag" variable which stops the execution or loop and scrolling stops...here goes the code:

public void run() {

addMouseMotionListener(this);
addMouseListener(this);
for(;;) {
try {
repaint();
Thread.sleep(20);
if (xaxis<msglen){
xaxis=640;
}
xaxis=xaxis-2;
if (stopflag)
break;
}
catch(InterruptedException e){}
}
}

now how to re run the this method again.

retesh_gondal
10-01-2004, 02:02 PM
hi,
i am able to stop and run thread...now another problem...

i have an array of 10 elements. Every element has some string. I concatenate all 10 elements to make 1 string ...this string then scrolls....now i want to change color of a particular string on which i take my mouseover.

Plz help

buntine
10-01-2004, 10:21 PM
labelName.addMouseMotionListener(new MouseMotionListener()
{
public void mouseMoved(MouseEvent me)
{
labelName.setForeground(new Color(100, 150, 200));
}
});

You should probably split that up and put the event handler in a new file rather than just making it anonymous.

Is that what your after? It should change the text color of the label when you mouse over it.

Regards.

retesh_gondal
10-02-2004, 03:02 AM
thanks for replying...

i want something similar to this....
logic u hve given will change the color of entire string...but i want that out of 10 string ...the one on which i take my mouseouve shoud change the color....rest 9 strings should remain unchanged.

I wonder if i'll hve to make 10 diffrent labels...