Question: Java problem!! Instructions: 1. Initial configuration The application shall create a window with two buttons and a label. The first button shall be labeled Start.

Java problem!!

Instructions:

1. Initial configuration

The application shall create a window with two buttons and a label.

The first button shall be labeled "Start".

The second buttons shall be labeled "Reset".

The label shall display the elapsed time, in 0.01 second increments.

The text in the label should be centered vertically and horizontally.

The label shall be easy to read. This example uses 36-point, bold Arial as the font. (Hint: see java.awt.Font)

The initial window looks like this:

Java problem!! Instructions: 1. Initial configuration The application shall create a window

2. Clicking the Start button:

Clicking the Start button, starts the timer.

The button caption changes to "Pause".

The label updates each 0.01 of a second to reflect elapsed time.

Here is an example of what the window looks like after the Start button is clicked:

with two buttons and a label. The first button shall be labeled

3. Clicking the Pause button:

Clicking the Pause button, stops the timer.

The button caption changes to "Continue".

The output label stops counting elapsed time.

Here is an example of what the window looks like after the Stop button is clicked:

"Start". The second buttons shall be labeled "Reset". The label shall display

4. Clicking the Continue Button

Clicking the Continue button, restarts the timer.

The button caption changes to "Pause".

The output label resumes counting elapsed time, adding to the elapsed time. That is, the next update will indicate 0.01 seconds after the time displayed during pause

the elapsed time, in 0.01 second increments. The text in the label

5. Clicking the Reset Button

Clicking the Reset button, returns the timer to the initial configuration.

If the timer is running, it is stopped.

The caption of the first button changes to "Start".

The output label reverts to "0.00 seconds".

should be centered vertically and horizontally. The label shall be easy to

Note:

Use java.lang.Thread rather than java.util.Timer

You may assume that the Thread.sleep is accurate enough for this implementation. That is, you can assume that every call the Thread.sleep(10) is 10 milliseconds long. So, after calling Thread.sleep(10), the display can be updated by 0.01 seconds.

Here is my code so far:

public class MyTimer extends javax.swing.JFrame { public MyTimer(){ super("My Timer"); setLocation(25, 25); setSize(400, 300); setDefaultCloseOperation(DISPOSE_ON_CLOSE); // create a toolbar javax.swing.JPanel toolbar = new javax.swing.JPanel(); add(toolbar, java.awt.BorderLayout.NORTH); // create a button javax.swing.JButton button1; javax.swing.JButton button2; button1 = new javax.swing.JButton("Start"); button2 = new javax.swing.JButton("Reset"); toolbar.add(button1); toolbar.add(button2); // finally, set the window to be visible setVisible(true); }

/** * The application method * @param args The command-line arguments */ public static void main(String[] args) { new MyTimer(); } }

My Timer Start Reset 0.00 Seconds My Timer Start Reset 0.00 Seconds

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!