import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JTextField; public class PizzaOrder { private JComboBox createToppingsMenu() { JComboBox comboBox = new JComboBox(); comboBox.addItem("Pepperoni"); comboBox.addItem("Sausage"); comboBox.addItem("Pinapple"); return comboBox; } private JComboBox createGetMenu() { JComboBox combo1Box = new JComboBox(); combo1Box.addItem("Delivery"); combo1Box.addItem("Pick Up"); return combo1Box; } private JPanel createNamePanel() { JPanel namePanel = new JPanel(); namePanel.add (new JLabel("Name: ")); namePanel.add (new JTextField(15)); return namePanel; } private JPanel createAddressPanel() { JPanel addressPanel = new JPanel(); addressPanel.add (new JLabel("Address: ")); addressPanel.add (new JTextField(15)); return addressPanel; } private JPanel createPhonePanel() { JPanel phonePanel = new JPanel(); phonePanel.add (new JLabel("Phone Number: ")); phonePanel.add (new JTextField(15)); return phonePanel; } private JPanel createButtonPanel() { JPanel buttonPanel = new JPanel(); buttonPanel.add (new JButton("Place order")); buttonPanel.add (new JButton("Cancel order")); return buttonPanel; } public static void main(String[] args) { JFrame f = new JFrame(); f.setTitle("Pizza Order"); PizzaOrder order = new PizzaOrder(); Container contentPane = f.getContentPane(); JPanel namePanel = order.createNamePanel(); contentPane.add(namePanel, BorderLayout.SOUTH); JPanel addressPanel = order.createAddressPanel(); contentPane.add(addressPanel, BorderLayout.SOUTH); JPanel phonePanel = order.createPhonePanel(); contentPane.add(phonePanel, BorderLayout.SOUTH); JComboBox comboBox = order.createToppingsMenu(); contentPane.add(comboBox, BorderLayout.CENTER); JComboBox combo1Box = order.createGetMenu(); contentPane.add(combo1Box, BorderLayout.CENTER); JPanel buttonPanel = order.createButtonPanel(); contentPane.add(buttonPanel, BorderLayout.EAST); f.setSize(500, 500); f.setVisible(true); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)