FileDocCategorySizeDatePackage
Shout.javaAPI DocExample1817Thu Nov 29 11:01:48 GMT 2001None

Shout.java

import java.applet.*;
import java.awt.*;
import java.awt.event.*;


public class Shout extends Applet implements ItemListener
{	
	private Label title;
	private Checkbox someTimes, always, never;
	private Panel pan1,pan2,pan3,pan4,pan5;
	private TextField answerBox;
	//Graphics g;
	
    public void init()
    { 
    	setLayout(new BorderLayout(10,10));

    	pan1 = new Panel();   	
    	pan1.setBackground(Color.cyan);
    	this.add("North",pan1);
		title = new Label("Do you understand these lectures?");	
		pan1.add(title);
	
		never = new Checkbox("Never");	  			
		pan2=new Panel();
		pan2.setBackground(Color.red);
		this.add("West",pan2);
		pan2.add(never);
		never.addItemListener(this);

		someTimes = new Checkbox("Sometimes");	
		pan3=new Panel();
	  	pan3.setBackground(Color.yellow);
	  	this.add("Center",pan3);
	  	pan3.add(someTimes); 
	  	someTimes.addItemListener(this);
	  	
	  	always = new Checkbox("Always");
	  	pan4=new Panel();
	  	pan4.setBackground(Color.gray);
	  	this.add("East",pan4);
	  	pan4.add(always);
   		always.addItemListener(this);	 
		
		
  	 	answerBox = new TextField(16);
  	 	pan5=new Panel();
	  	pan5.setBackground(Color.green);
	  	this.add("South",pan5);	  	 
  	 	pan5.add(answerBox);
  	 }
  	public void paint(Graphics g)
    {
    }
      	
    public void itemStateChanged(ItemEvent ae)
    {
     	if (ae.getSource() == never)
     	{
      		answerBox.setText("Show your face!");
      	}              
      		if (ae.getSource() == someTimes)
     	{
      		answerBox.setText("Raise your hand...");
      	}               		
      		if (ae.getSource() == always)
     	{
      		answerBox.setText("Lift a flag.");
      	}        
      	repaint();       		 		
    }

 
      		
 }