0
    try {
                Lines.setText("HI");
                Thread.sleep(300);
                Lines.setText("Hello");
                Thread.sleep(300);
                Lines.setText("World");
            } catch (InterruptedException e1) {

                e1.printStackTrace();
            }

I am trying to get my Label(Lines) to change its text every short intervals.How should I do it.. Thx, any help is appreciated !!

  • Please specify what problem exactly that you are running into, including any error messages or describe that unwanted state and the perfect state. – Stephan-v Jul 29 '17 at 07:06

1 Answers1

0

Try this:

public class SimpleThread extends Thread{   
static int x=0;
@Override
public void run(){
    for (int i = 0; i < 50; i++) {
        System.out.println(x+" "+i+" "+getName());
        try{
            x++;
            sleep((int)(Math.random()*1000));
        } catch (InterruptedException ex) {
            System.out.println("Sucedió un error");
        }
    }
    System.out.println("Hecho! "+getName());
}

in this case it's a template that make random numbers. this is the main class:

 public static void main(String[] args) {
    new SimpleThread().start();
    new SimpleThread().start();
}

you can change the numbers for your lines.