Timer or other idea required to allow code to continue execution after calling method and JOptionPane

后端 未结 3 1442
[愿得一人]
[愿得一人] 2020-12-04 02:58

I need a way to allow my program to keep running code after this method is called.

Currently, it waits for half an hour, gets the info, stores it to the object WeatherCar

3条回答
  •  [愿得一人]
    2020-12-04 03:45

    Closing a modal dialog after some delay and updating the display behind a modal dialog are distinct issues.

    • In this example, a javax.swing.Timer is used to mark time, and the dialog is closed when a counter reaches zero or the user dismisses it.

    • A modal dialog only blocks user interaction. Add a modal dialog to this example to see that GUI updates continue in response to the javax.swing.Timer.

      public void run() {
          ...
          f.setVisible(true);
          JOptionPane.showMessageDialog(dt, TITLE);
      }
      

提交回复
热议问题