Jlabel not updating

Additionally the simple date format is inside the while loop and so created fresh each time, this is unnecessary since trivial to ensure it can only be accessed from one thread at a time. While the method shown above certainly works Java FX 2 provides a more developer friendly way of achieving the same result.

Rather than creating a Runnable you create a Task which comes complete with a couple of thread safe properties that can be used to update the UI with the minimum of fuss. As you can see this is similar to the first example just without the less than beautiful anonymous inner Runnable.

i set the label to public and i tried to invoke set Text() on it from the other class, but it doesnt change it in the GUI.

i printed the get Text() method of the label and it's identical to what i tried to set it to be, but it just isnt displaying the correct text.

If the new information is coming from the another thread however care must be taken to ensure that the update is performed on the Java FX thread.

I have attempted to use concurrency to update the labels, as suggested in other questions on this site, but I have had no luck with the labels updating.

The label has its text property bound to a Simple String Property.

The application then spawns a new thread which simply formats the current time and sets the value of the property.

Visible(true); public main(){ //JLabel // Make the lable final..we can access from witin // the listener...

final JLabel cookies = new JLabel(); Text("Cookies:" num Cookies); //JButton JButton click = new JButton("Click"); Action Listener(new Action Listener()); import

Leave a Reply