java - How to update a label to make it display new text? -
I am making an application in Netbeen and want a status label that shows what the program is in any way Is the moment There is a ton of code, but it's too much to do: Just pretend that label is a label that has already been put into the program and each function is an expensive task that takes seconds.
statusLabel.setText ("Complete Task 1"); System.out.println ("Completing the Task 1"); . This.getFrame () repaint (); // I call this function and two functions below it but the label still does not change. StatusLabel.updateUI (); // does not seem to do much statusLabel.revalidate (); // does not seem to do much this.completeTask1 (); StatusLabel.setText ("Task 2 Complete"); System.out.println ("Completing Task 2"); StatusLabel.revalidate (); . This.getFrame () repaint (); ...
It runs until the UI has completed 4 tasks. Labels are not updated during the entire process until each task is completed, and then it says "Completing the work 4" System.out.println calls work perfectly. Actually I am thinking that what I should do to show the new text to the label which is set to it.
The answer to COD is correct, but I want to go with the class:
A dedicated class In order to perform long GUI-interacting tasks in a specific thread.
This is the right tool for your problem.
Comments
Post a Comment