Question: Write a Java program with a Graphical User Interface that will function as a stopwatch. the GUI only needs a button and a label to

Write a Java program with a Graphical User Interface that will function as a stopwatch. the GUI only needs a button and a label to display the elapsed time.  Write a Java program with a Graphical User Interface that will

1 of 1 COMP163 Stopwatch Program Write a Java program with a Graphical User Interface that will function as a stopwatch. The GUI only needs a button and a label to display the elapsed time. start stop running start 12.61 seconds The program will need a class instance variable called startTime to keep track of the time when the start button was pressed. This value should be a long, which is just like an int, but can store much larger numbers. It should be initialized to zero The actionPerformed method should be structured as shown below. Note in the IF statement there are two equals signs public void actionPerformed (java.awt.event.ActionEvent thing) ( if (startTime0) // create an object of the java.util.Date class l call the getTime ) method on the Date object and save the returned value in startTime /change the text of the button else // create an object of the java.util.Date class // call the getTime ) method on the Date object. Subtract startTime from the returned value to get the elapsed time /Convert the elapsed time to a double and divide by 1000 to get seconds //Display the result // change the text of the button // set startTime to zero

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!