FileDocCategorySizeDatePackage
OrderForm.javaAPI DocExample1434Fri Feb 14 02:12:50 GMT 1997None

OrderForm

public class OrderForm extends Applet implements ActionListener

Fields Summary
Panel
condimentsPanel
CheckboxGroup
entreeGroup
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

		takeOrder();
	
public voidinit()


	   
		condimentsPanel.add( new Checkbox("Ketchup"));
		condimentsPanel.add( new Checkbox("Mustard"));
		condimentsPanel.add( new Checkbox("Pickles"));

		Checkbox c;
		Panel entreePanel = new Panel();
		entreePanel.add( c = new Checkbox("Beef") );
		c.setCheckboxGroup( entreeGroup );
		entreePanel.add( c = new Checkbox("Chicken") );
		c.setCheckboxGroup( entreeGroup );
		entreePanel.add( c = new Checkbox("Veggie") );
		c.setCheckboxGroup( entreeGroup );
		entreeGroup.setCurrent( c );

		Panel orderPanel = new Panel();
		Button orderButton = new Button("Place Order");
		orderButton.addActionListener( this );
		orderPanel.add( orderButton );

		setLayout( new GridLayout(3, 1) );
		add( entreePanel );
		add( condimentsPanel );
		add( orderPanel );
	
voidtakeOrder()

		Checkbox c = entreeGroup.getCurrent();
			System.out.println( c.getLabel() + " sandwich" );

		Component [] components = condimentsPanel.getComponents();
		for (int i=0; i< components.length; i++)
			if ( (c = (Checkbox)components[i]).getState() )
				System.out.println( "With " + c.getLabel() );
		System.out.println("Thank you, drive through...");