The following code implements a Java Pasta timer that looks like the application below. • Once the start button is pressed the timer will count to two minutes. • The timer can be stopped by pressing stop. • When the timer is finished, it should pop-up an appropriate dialog box that states the time is up. You are given a partial implementation of program. Fill out the missing code to complete the program import javax.swing.*; import java.awt.event.*; import javax.swing.border.*; public class PastaTimerApp extends implements {  private JProgressBar progrBar;  private JButton startButton, stopButton;  private JLabel textLabel;  private PastaTimer PastaTimer;  public PastaTimerApp() {  JPanel p = new JPanel();  p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));  p.setBorder(new TitledBorder("Pasta Timer:"));  progrBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 540);  textLabel = new JLabel(" 0 Seconds "); p.add(progrBar);  p.add(textLabel);  // Initialize buttons and add action listeners  JPanel controls = new JPanel();  controls.add(startButton);  controls.add(stopButton);  this.getContentPane().add("Center", p);  this.getContentPane().add("South", controls);  this.setSize(600, 130);  //Set default close operation and make it visible.  this.PastaTimer =  } //end PastTimerApp() constructor method  public void actionPerformed(ActionEvent e) {  } //end actionPerformed public static void main(String[] args) {  } //end main }//end PastaTimerApp class PastaTimer extends {  private int numberSeconds = 0;  private boolean running = true;  private JProgressBar progressReference;  private JLabel textLabel;  public PastaTimer(JProgressBar progressReference, JLabel textLabel){  } // end PastaTimer constructor  public void run() {  while (running) {  if (this.updateProgress() == false) { // stop the thread  try {  Thread.currentThread().sleep(100);  }  } //end while  } //end run  // Displays a message and returns false when timer is done.  private boolean updateProgress() {  int current = progressReference.getValue();  int updateTo = ++current;  if (updateTo <= 540) {  this.progressReference.setValue(updateTo);  this.textLabel.setText(" " + updateTo + " Seconds ");  return true;  } else {  this.running = false;  this.displayDialog();  return false;  }//end if else  } //end update progress  public void stopTimer() { this.running = false;}  private void displayDialog() {  } }

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter7: Input/output Technology
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question

The following code implements a Java Pasta timer that looks like the application below.
• Once the start button is pressed the timer will count to two minutes.
• The timer can be stopped by pressing stop.
• When the timer is finished, it should pop-up an appropriate dialog box that states the time
is up.
You are given a partial implementation of program. Fill out the missing code to complete the
program

import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class PastaTimerApp extends implements {
 private JProgressBar progrBar;
 private JButton startButton, stopButton;
 private JLabel textLabel;
 private PastaTimer PastaTimer;
 public PastaTimerApp() {
 JPanel p = new JPanel();
 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
 p.setBorder(new TitledBorder("Pasta Timer:"));
 progrBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 540);
 textLabel = new JLabel(" 0 Seconds ");

p.add(progrBar);
 p.add(textLabel);

 // Initialize buttons and add action listeners

 JPanel controls = new JPanel();
 controls.add(startButton);
 controls.add(stopButton);
 this.getContentPane().add("Center", p);
 this.getContentPane().add("South", controls);
 this.setSize(600, 130);
 //Set default close operation and make it visible.
 this.PastaTimer =
 } //end PastTimerApp() constructor method

 public void actionPerformed(ActionEvent e) {
 } //end actionPerformed

public static void main(String[] args) {
 } //end main
}//end PastaTimerApp
class PastaTimer extends {
 private int numberSeconds = 0;
 private boolean running = true;
 private JProgressBar progressReference;
 private JLabel textLabel;
 public PastaTimer(JProgressBar progressReference, JLabel textLabel){
 } // end PastaTimer constructor
 public void run() {
 while (running) {
 if (this.updateProgress() == false) { // stop the thread

 try {
 Thread.currentThread().sleep(100);
 }
 } //end while 

} //end run
 // Displays a message and returns false when timer is done.
 private boolean updateProgress() {
 int current = progressReference.getValue();
 int updateTo = ++current;
 if (updateTo <= 540) {
 this.progressReference.setValue(updateTo);
 this.textLabel.setText(" " + updateTo + " Seconds ");
 return true;
 } else {
 this.running = false;
 this.displayDialog();
 return false;
 }//end if else
 } //end update progress
 public void stopTimer() { this.running = false;}
 private void displayDialog() {
 }
}

Pasta Timer
Pasta Timer:
51 Seconds
Start
Stop
X
Transcribed Image Text:Pasta Timer Pasta Timer: 51 Seconds Start Stop X
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
A+ Guide to Hardware (Standalone Book) (MindTap C…
A+ Guide to Hardware (Standalone Book) (MindTap C…
Computer Science
ISBN:
9781305266452
Author:
Jean Andrews
Publisher:
Cengage Learning
Enhanced Discovering Computers 2017 (Shelly Cashm…
Enhanced Discovering Computers 2017 (Shelly Cashm…
Computer Science
ISBN:
9781305657458
Author:
Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L