I'm trying to show the actual system time display on a text field when you click the button. So far it it only shows the live result if you click the button each time. I'm struggling to attach the ActionListener in so that the time can continuously update itself.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date time = new Date();
dateFormat.format(time);
ActualTime.setText(dateFormat.format(time));
Calendar cal = Calendar.getInstance();
ActualTime.setText(dateFormat.format(cal.getTime()));
}
Thank you for the edit to your question.
start()
on the Timer from within the JButton's ActionListener.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.