/** * @(#)pizzaForm.java * * * @author * @version 1.00 2007/4/19 */ import java.awt.*; import javax.swing.*; import java.awt.event.*; public class pizzaForm extends JFrame{ //Order Number Row JPanel orderRow = new JPanel(); JLabel orderNum = new JLabel("Order Number:", JLabel.RIGHT); JTextField orderCounter = new JTextField(7); //Pizza Size Row (Label) JPanel sizeRowL = new JPanel(); JLabel pizzaSize = new JLabel("Pizza Size:"); //Pizza Size Row (Selection) JPanel sizeRowS = new JPanel(); ButtonGroup allSizes = new ButtonGroup(); JRadioButton small = new JRadioButton("Small $8.99", false); JRadioButton medium = new JRadioButton("Medium $10.99", false); JRadioButton large = new JRadioButton("Large $12.99", true); //Topping Selection Row JPanel toppingRow = new JPanel(); JLabel top1 = new JLabel("Toppings:"); JLabel top2 = new JLabel("$1.00 each"); JCheckBox pepperoniCheck = new JCheckBox("Pepperoni"); JCheckBox greenPeppersCheck = new JCheckBox("Green Peppers"); JCheckBox mushroomsCheck = new JCheckBox("Mushrooms"); JCheckBox hamCheck = new JCheckBox("Ham"); JCheckBox hotPeppersCheck = new JCheckBox("Hot Peppers"); JCheckBox baconCheck = new JCheckBox("Bacon"); //Selection Handling Row JPanel selectRow = new JPanel(); JButton cancel= new JButton("Cancel"); JButton done = new JButton("Done"); JLabel priceLabel = new JLabel("Price:", JLabel.RIGHT); JTextField totalPrice = new JTextField(10); public pizzaForm() { //Main Layout Stuff super("Build Your Pizza"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridLayout table = new GridLayout(5,1); Container mainPane = getContentPane(); mainPane.setLayout(table); setVisible(true); //Order Number Row FlowLayout orderRowLayout = new FlowLayout(FlowLayout.CENTER); orderRow.setLayout(orderRowLayout); orderRow.add(orderNum); orderRow.add(orderCounter); orderCounter.setEditable(false); mainPane.add(orderRow); //Pizza Size Row (Label) FlowLayout sizeRowLayoutL = new FlowLayout(FlowLayout.LEFT); sizeRowL.setLayout(sizeRowLayoutL); sizeRowL.add(pizzaSize); mainPane.add(sizeRowL); //Pizza Size Row (Selection) //GridLayout sizeRowLayoutS = new GridLayout(1, 1); FlowLayout sizeRowLayoutS = new FlowLayout(FlowLayout.CENTER); sizeRowS.setLayout(sizeRowLayoutS); allSizes.add(small); allSizes.add(medium); allSizes.add(large); sizeRowS.add(small); sizeRowS.add(medium); sizeRowS.add(large); mainPane.add(sizeRowS); //Topping Selection Row GridLayout toppingRowLayout = new GridLayout(4, 2); toppingRow.setLayout(toppingRowLayout); toppingRow.add(top1); toppingRow.add(top2); toppingRow.add(pepperoniCheck); toppingRow.add(greenPeppersCheck); toppingRow.add(mushroomsCheck); toppingRow.add(hamCheck); toppingRow.add(hotPeppersCheck); toppingRow.add(baconCheck); mainPane.add(toppingRow); //Selection Handling Row FlowLayout selectRowLayout = new FlowLayout(FlowLayout.CENTER); selectRow.setLayout(selectRowLayout); selectRow.add(priceLabel); selectRow.add(totalPrice); totalPrice.setEditable(false); selectRow.add(done); selectRow.add(cancel); mainPane.add(selectRow); pack(); } public static void main(String[] args){ pizzaForm huzzah = new pizzaForm(); } }