I've tried so many time to where to put the '}' but error keeps coming out. So, where should I place the last '}' ?
What I have tried:
import java.text.*;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class PizzaOrderForm extends JFrame implements ActionListener {
double sizeCost, toppingCost, amount;
String msg = "";
JButton B,B1;
JLabel L, L1, L2,L3,L4,L5,L6,L7,L8;
JRadioButton RB,RB1,RB2;
ButtonGroup buttonGroup = new ButtonGroup();
JCheckBox C,C1,C2,C3,C4,C5;
DecimalFormat twoDigits;
public PizzaOrderForm()
{
JPanel panel = new JPanel();
L = new JLabel("MAMA MIA PIZZARIA");
L.setSize(500,600);
L.setFont(new Font("Serif",Font.BOLD,30));
panel.add(L);
add(panel,BorderLayout.NORTH);
JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayout(4,2));
L1 = new JLabel("Small:");
L2 = new JLabel("$4.99");
L3 = new JLabel("Medium:");
L4 = new JLabel("$6.99");
L5 = new JLabel("Large:");
L6 = new JLabel("$8.99");
L7 = new JLabel("Toppings:");
L8 = new JLabel("$0.50 each");
panel1.add(L1);
panel1.add(L2);
panel1.add(L3);
panel1.add(L4);
panel1.add(L5);
panel1.add(L6);
panel1.add(L7);
panel1.add(L8);
add(panel1,BorderLayout.WEST);
JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayout(4,1));
TitledBorder T = new TitledBorder("Size");
RB = new JRadioButton("Small");
RB1 = new JRadioButton("Medium");
RB2 = new JRadioButton("Large");
buttonGroup.add(RB);
buttonGroup.add(RB1);
buttonGroup.add(RB2);
panel2.setBorder(T);
panel2.add(RB);
panel2.add(RB1);
panel2.add(RB2);
add(panel2,BorderLayout.CENTER);
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout(FlowLayout.CENTER,1,2));
B = new JButton("Calculate");
B1 = new JButton("Exit");
panel3.add(B);
panel3.add(B1);
add(panel3,BorderLayout.SOUTH);
B.addActionListener(this);
B1.addActionListener(new ButtonListener());
JPanel panel4 = new JPanel();
panel4.setLayout(new GridLayout(7,1));
TitledBorder T1 = new TitledBorder("Toppings");
C = new JCheckBox("Pepperoni");
C1 = new JCheckBox("Italian Sausage");
C2 = new JCheckBox("Pineapple");
C3 = new JCheckBox("Extra Cheese");
C4 = new JCheckBox("Green Pepper");
C5 = new JCheckBox("Olived");
panel4.setBorder(T1);
panel4.add(C);
panel4.add(C1);
panel4.add(C2);
panel4.add(C3);
panel4.add(C4);
panel4.add(C5);
add(panel4,BorderLayout.EAST);
}
public void actionPerformed(ActionEvent e){
public double sizeCost()
{
if(RB.isSelected()){
return sizeCost = 4.99;
}
else if(RB1.isSelected()){
return sizeCost = 6.99;
}
else if(RB2.isSelected()){
return sizeCost = 4.99;
}
return sizeCost;
}
public double toppingCost()
{
if(C.isSelected()){
toppingCost += 0.50;
}
else if(C1.isSelected()){
toppingCost += 0.50;
}
else if(C2.isSelected()){
toppingCost += 0.50;
}
else if(C3.isSelected()){
toppingCost += 0.50;
}
else if(C4.isSelected()){
toppingCost += 0.50;
}
else if(C5.isSelected()){
toppingCost += 0.50;
}
return toppingCost;
}
public void calculate (double sizeCost, double toppingCost)
{
amount = sizeCost + toppingCost;
JOptionPane.showMessageDialog(this, msg+"Total: "+amount);
}
public static void main(String[]args)
{
PizzaOrderForm frame = new PizzaOrderForm();
frame.setSize(500,300);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
System.exit(0);
}
}