当您单击按钮时,我试图在文本字段上显示实际的系统时间显示。到目前为止,如果您每次单击按钮,它只会显示实时结果。我正在努力附加 ActionListener 以便时间可以不断更新。
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()));
}