I want to update a JLabel
through a separate function class. I'm doing a live bubblesort using a thread, but it's not updating even though the value has changed; the text on the JLabel
remains the same.
public class bubbleSort extends Main implements Runnable{
@Override
public void run(){
String holder;
for(int i=0;i<5;i++){
System.out.println( Main.str1.getText().compareTo(Main.str2.getText()));
if(Main.str1.getText().compareTo(Main.str2.getText())>0){
holder=Main.str1.getText();
Main.str1.setText(Main.str2.getText());
Main.str2.setText(holder);
}
try {
Thread.sleep(1000);
} catch (InterruptedException e){
}
}
}
}