-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDialogTimer.java
More file actions
33 lines (24 loc) · 1018 Bytes
/
Copy pathDialogTimer.java
File metadata and controls
33 lines (24 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import javax.swing.JOptionPane;
import java.util.*;
public class DialogTimer
{
public static void main(String[] args)
{
int time1, time2, milli1, milli2, sec1,
sec2, timeDifference;
final int MILLISECS_IN_SECOND = 1000;
GregorianCalendar before = new GregorianCalendar();
milli1 = before.get(GregorianCalendar.MILLISECOND);
sec1 = before.get(GregorianCalendar.SECOND);
time1 = MILLISECS_IN_SECOND * sec1 + milli1;
JOptionPane.showConfirmDialog
(null, "Is stealing ever justified?");
GregorianCalendar after = new GregorianCalendar();
milli2 = after.get(GregorianCalendar.MILLISECOND);
sec2 = after.get(GregorianCalendar.SECOND);
time2 = MILLISECS_IN_SECOND * sec2 + milli2;
timeDifference = time2-time1;
JOptionPane.showMessageDialog(null, "It took " +
timeDifference + " milliseconds for you to answer.");
}
}