Guest User

Untitled

a guest
Oct 23rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. import java.util.*;
  3.  
  4. public class DialogTimer
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         int time1, time2, milli1, milli2, sec1, sec2, timeDifference;
  9.         GregorianCalendar before = new GregorianCalendar();
  10.         milli1 = before.get(Calendar.MILLISECOND);
  11.         sec1 = before.get(Calendar.SECOND);
  12.         time1 = 1000 * sec1 + milli1;
  13.        
  14.         JOptionPane.showConfirmDialog(null, "Is stealing ever justified? ");
  15.        
  16.         GregorianCalendar after = new GregorianCalendar();
  17.         milli2 = after.get(Calendar.MILLISECOND);
  18.         sec2  = after.get(Calendar.SECOND);
  19.         time2 = 1000 * sec2 + milli2;
  20.        
  21.         timeDifference = time2 - time1;
  22.         JOptionPane.showMessageDialog(null,"It took "+timeDifference+" milliseconds for you to answer");
  23.         System.exit(0);
  24.     }
  25. }
Add Comment
Please, Sign In to add comment