Question: import javax.swing.*; import java.awt.*; import java.awt.event.*; /** The OrderCalculatorGUI class creates the GUI for the Brandi's Bagel House application. */ public class OrderCalculatorGUI extends JFrame
import javax.swing.*; import java.awt.*; import java.awt.event.*; /** The OrderCalculatorGUI class creates the GUI for the Brandi's Bagel House application. */ public class OrderCalculatorGUI extends JFrame { private BagelPanel bagels; // Bagel panel private ToppingPanel toppings; // Topping panel private CoffeePanel coffee; // Coffee panel private GreetingPanel banner; // To display a greeting private JPanel buttonPanel; // To hold the buttons private JButton calcButton; // To calculate the cost private JButton exitButton; // To exit the application private final double TAX_RATE = 0.06; // Sales tax rate /** Constructor */ public OrderCalculatorGUI() { // Display a title. setTitle("Order Calculator"); // Specify an action for the close button. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a BorderLayout manager. setLayout(new BorderLayout()); // Create the custom panels. banner = new GreetingPanel(); bagels = new BagelPanel(); toppings = new ToppingPanel(); coffee = new CoffeePanel(); // Create the button panel. buildButtonPanel(); // Add the components to the content pane. add(banner, BorderLayout.NORTH); add(bagels, BorderLayout.WEST); add(toppings, BorderLayout.CENTER); add(coffee, BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); // Pack the contents of the window and display it. pack(); /* * MAKE THE PANEL VISIBLE */ } /** The buildButtonPanel method builds the button panel. */ private void buildButtonPanel() { // Create a panel for the buttons. buttonPanel = new JPanel(); // Create the buttons. calcButton = new JButton("Calculate"); exitButton = new JButton("Exit"); // Register the action listeners. calcButton.addActionListener(new CalcButtonListener()); exitButton.addActionListener(new ExitButtonListener()); // Add the buttons to the button panel. buttonPanel.add(calcButton); buttonPanel.add(exitButton); } /** Private inner class that handles the event when the user clicks the Calculate button. */ /* * Create your inner class that computes the total do * Look to line 73 for your class name Here is body of the implemented * method that you have to code. Copy and paste this body into your class/method * BEGINING OF COPY // Variables to hold the subtotal, tax, and total double subtotal, tax, total; // Calculate the subtotal. subtotal = bagels.getBagelCost() + toppings.getToppingCost() + coffee.getCoffeeCost(); // Calculate the sales tax. tax = subtotal * TAX_RATE; // Calculate the total. total = subtotal + tax; // Display the charges. JOptionPane.showMessageDialog(null, String.format("Subtotal: $%,.2f " + "Tax: $%,.2f " + "Total: $%,.2f", subtotal, tax, total)); * END OF COPY */ /** Private inner class that handles the event when the user clicks the Exit button. */ /* * Create your inner class that cause the entire program/system to EXIT (hint) * Look to line 74 for your class name */ } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
