/*

This program gets EmployeeID from GUI, and uses it to retrieve Employee object.

*/
import java.awt.*;
import java.applet.*;
public class EmployeeID extends Applet {
   Employee a = null; 
   EmployeeVector ev; 
   TextField idText; 
   int id = 0;    
   public void init() {
      ev = new EmployeeVector();
      add(new Label("Employee ID:"));   
      idText = new TextField("", 5);
      add(idText);             
   }
   public boolean action(Event evt, Object obj) {
      if (evt.target == idText) { 
            
          try {
		id = Integer.valueOf(idText.getText()).intValue();			    
	  } catch (NumberFormatException e) {
		showStatus("Error: ID must be a number");
		return true;        
	  }
            
          a = ev.getEmployeeByID(id); 
          if (null == a) {    
         	showStatus("Error: Invalid Employee ID");
		return true;        
	  }
      }
      repaint();
      return true;
   }
   public void paint(Graphics g)  {
      if ( null != a) 
          g.drawString(("Employee  " + a),1,70);
      else 
          g.drawString("Employee  ???",1,70);
   }
}
// 
//