In JavaFX, how can I display values which continuously change with time using "label" ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Excellent responses, thank you jewelsea for your input it helped me a lot.
I updated the DigitalClock posted previously in a leaner format using Java 8. Using the additions of Java 8 like Date API and of course the lambdas.
I like Sebastian's binding answer.
For variety, here is another sample of modifying a label text based upon time. The sample displays a digital clock readout in a label whose text changes each second using an Timeline.
Digital clock sample output:
How about using SimpleDateFormat? There's no need for the StringUtilities class!
There are numerous ways to achieve that, the most convenient would be to use JavaFX's DataBinding mechanism:
This way, every time your valueProperty gets changed by calling it's set method, the label's text is updated.