Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

I need to create this: This is my code thus far: package cis355a_avargas_lab_week3; import java.*; import java.event.ActionEvent; import...

I need to create this:

This is my code thus far: package cis355a_avargas_lab_week3;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.text.DecimalFormat;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JCheckBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

import javax.swing.JTextArea;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

public class BurgersRU extends JFrame implements ActionListener 

{

  //components

JRadioButton singleBurgerRbtn = new JRadioButton("Single burger");

JRadioButton doubleBurgerRbtn = new JRadioButton("Double burger");

JCheckBox cheeseCbx = new JCheckBox("Add cheese");

JCheckBox baconCbx = new JCheckBox("Add bacon");

JCheckBox mealCbx = new JCheckBox("Make it a meal");

JTextField itemPriceTxt = new JTextField(8);

JTextField orderQuantityTxt = new JTextField(8);

JTextField orderTotalTxt = new JTextField(8);

JTextArea receiptArea = new JTextArea(5,25);

JMenuBar menuBar = new JMenuBar();

JMenu exitMenu = new JMenu("File");

    JMenu exitItem = new JMenu("Exit");

JMenu orderMenu = new JMenu("Order");

JMenuItem addItem = new JMenuItem("Add to order");

JMenuItem clearItem = new JMenuItem("Clear for next order");

JMenuItem newOrderItem = new JMenuItem ("New order");

ButtonGroup burgerGroup = new ButtonGroup();

JLabel itemPriceLb = new JLabel("Item Price");

JLabel QtyLb = new JLabel("Quantity");

JLabel orderTotalLb = new JLabel("Order Total");

JLabel orderLb = new JLabel("Your order");

double total = 0;

int qty = 0;

//constructor

public BurgersRU(){

burgerGroup.add(singleBurgerRbtn);

burgerGroup.add(doubleBurgerRbtn);

//container

Container c = getContentPane();

c.setLayout(new BorderLayout());

JPanel northPanel = new JPanel();

JPanel southPanel = new JPanel();

c.add(northPanel, BorderLayout.NORTH);

c.add(southPanel, BorderLayout.SOUTH);

//layout

northPanel.add(singleBurgerRbtn);

northPanel.add(doubleBurgerRbtn);

northPanel.add(cheeseCbx);

northPanel.add(baconCbx);

northPanel.add(mealCbx);

southPanel.add(itemPriceLb);

southPanel.add(itemPriceTxt);

southPanel.add(QtyLb);

southPanel.add(orderQuantityTxt);

southPanel.add(orderTotalLb);

southPanel.add(orderTotalTxt);

northPanel.setLayout(new FlowLayout());

southPanel.add(receiptArea);

southPanel.setLayout(new FlowLayout());

setJMenuBar(menuBar);

    menuBar.add(exitMenu);

menuBar.add(orderMenu);

orderMenu.add(addItem);

orderMenu.add(clearItem);

orderMenu.add(newOrderItem);

exitMenu.add(exitItem);

addItem.addActionListener(this);

exitItem.addActionListener(this);

clearItem.addActionListener(this);

newOrderItem.addActionListener(this);

}

//action performed

public void actionPerformed(ActionEvent e) {

if(e.getSource().equals(exitItem)){

System.exit(0);

}

if(e.getSource().equals(clearItem)){

singleBurgerRbtn.setSelected(false);

doubleBurgerRbtn.setSelected(false);

cheeseCbx.setSelected(false);

baconCbx.setSelected(false);

mealCbx.setSelected(false);

}

if(e.getSource().equals(newOrderItem)){

singleBurgerRbtn.setSelected(false);

doubleBurgerRbtn.setSelected(false);

cheeseCbx.setSelected(false);

baconCbx.setSelected(false);

mealCbx.setSelected(false);

orderLb.setText("");

itemPriceTxt.setText("");

orderQuantityTxt.setText("");

orderTotalTxt.setText("");

total = 0;

qty = 0;

}

//qty = Integer.parseInt(orderQuantityTxt.getText());

if(e.getSource().equals(addItem)){

double price = 0;

if (singleBurgerRbtn.isSelected()){

price = 3.50;

total += 3.50;

qty +=1;

receiptArea.append("Single Burger at: $3.50 each");

}

else if (doubleBurgerRbtn.isSelected()){

price = 4.75;

total += 4.75;

qty +=1;

receiptArea.append("Double Burger: $4.75");

}

else{

receiptArea.setText("n No selection made");

}

if (cheeseCbx.isSelected()){

price = .50;

total +=.50;

receiptArea.append("nAdd cheese for: $0.50");

}

if (baconCbx.isSelected()){

price = 1.25;

total +=1.25;

receiptArea.append("nAdd Bacon for: $1.25");

}

if(mealCbx.isSelected()){

price = 4.00;

total +=4.00;

receiptArea.append("nMake it a Meal: $4.00");

}

DecimalFormat df = new DecimalFormat("$##.00");

itemPriceTxt.setText("n"+df.format(price));

orderQuantityTxt.setText("n"+qty);

orderTotalTxt.setText("n"+df.format(total));

}

}

package cis355a_avargas_lab_week3;

import javax.swing.JFrame;

public class Lab3Main {

  public static void main(String[] args) {

// TODO Auto-generated method stub

BurgersRU b = new BurgersRU();

b.setVisible(true);

b.setSize(700,400);

b.setTitle("Burger Barn");

b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

Can you help me change the GUI to actually look like it should?

Show more
Files: pic1.png
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question