Once I start running the timer, how do I get it to return how long has passed? Can this timer be set visible?
相关问题
- 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
The object that you pass as second argument to the Timer constructor implements ActionListener. Through that interface it receives a call to its actionPerformed method upon each alarm from the timer. The actionPerformed method has an ActionEvent parameter whose method getWhen gives the timestamp. You will need to store the original timestamp somewhere accessible if you want the ActionListener to compute the elapsed time.
A Swing Timer is a mechanism with no graphical representation of its own. If you like, your ActionListener can implement a graphical representation of the timer. It can be a graphic component such as a JPanel and its actionPerformed method can cause it to respond visibly, perhaps by drawing something, each time that the timer goes off.