//PizzaPanel.java Author: Carien Anderson
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.JOptionPane;
import java.awt.event.*;
public class PizzaPanel extends JPanel
{
public PizzaPanel()
{
setLayout(new BorderLayout());
setBackground (Color.white);
setPreferredSize (new Dimension(700,280));
//North panel
JPanel ppan1 = new JPanel();
JLabel l1 = new JLabel("Lets Eat!");
ppan1.add(l1);
ppan1.setBackground(Color.green);
add(ppan1, BorderLayout.NORTH);
//West panel
JPanel ppan2 = new JPanel();
JPanel quantityPanel = new JPanel();
JLabel quantity = new JLabel ("Quantity: ");
String[] count = {"0", "1", "2", "3", "4", "5"};
JComboBox quantityCount = new JComboBox (count);
quantityPanel.setBackground(Color.red);
quantityPanel.add(quantity);
quantityPanel.add(quantityCount);
JPanel sizePanel = new JPanel();
JLabel size = new JLabel("Size: ");
String[] type = {"Single", "Medium", "Large"};
JComboBox sizeType = new JComboBox (type);
sizePanel.setBackground(Color.red);
sizePanel.add(size);
sizePanel.add(sizeType);
JPanel crustPanel = new JPanel();
JLabel crust = new JLabel("Crust: ");
String[] type2 = {"Hand-Tossed", "Pan", "Cheese"};
JComboBox crustType = new JComboBox (type2);
crustPanel.setBackground(Color.red);
crustPanel.add(crust);
crustPanel.add(crustType);
ppan2.add(quantityPanel);
ppan2.add(sizePanel);
ppan2.add(crustPanel);
ppan2.setLayout (new BoxLayout(ppan2, BoxLayout.Y_AXIS));
ppan2.setBackground(Color.red);
add (ppan2, BorderLayout.WEST);
//Center
JPanel topping = new JPanel();
topping.setLayout (new BoxLayout (topping, BoxLayout.Y_AXIS));
topping.setBackground (Color.red);
TitledBorder border2 = BorderFactory.createTitledBorder ("Toppings");
border2.setTitleJustification (TitledBorder.LEFT);
topping.setAlignmentY(Component.CENTER_ALIGNMENT);
topping.setPreferredSize(new Dimension (80,75));
JCheckBox peperonni = new JCheckBox("Peperonni");
JCheckBox sausage = new JCheckBox("Sausage");
JCheckBox onion = new JCheckBox("Onion");
JCheckBox ham = new JCheckBox("Ham");
JCheckBox mushroom = new JCheckBox("Mushroom");
JCheckBox pepper = new JCheckBox("Peppers");
topping.setBorder(border2);
peperonni.setBackground(Color.red);
sausage.setBackground(Color.red);
onion.setBackground(Color.red);
ham.setBackground(Color.red);
mushroom.setBackground(Color.red);
pepper.setBackground(Color.red);
topping.add(peperonni);
topping.add(sausage);
topping.add(onion);
topping.add(ham);
topping.add(mushroom);
topping.add(pepper);
add(topping, BorderLayout.CENTER);
//South
JPanel exitPanel = new JPanel();
exitPanel.setLayout(new BoxLayout (exitPanel, BoxLayout.X_AXIS));
exitPanel.setBackground (Color.green);
exitPanel.add(Box.createHorizontalGlue());
JButton button = new JButton ("Logout");
ButtonListener listener = new ButtonListener();
button.addActionListener (listener);
exitPanel.add(button);
add(exitPanel, BorderLayout.SOUTH);
}
class cancelListener implements ActionListener
{
public void actionPerformed(ActionEvent ev)
{
int n = JOptionPane.showConfirmDialog(frame,
"Are You sure you want to Close?",
"Confirm Log Off",
JOptionPane.YES_NO_OPTION);
}
}
}
rena0514 0 Junior Poster in Training
stultuske 1,116 Posting Maven Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.