FileDocCategorySizeDatePackage
Cooler.javaAPI DocExample1592Tue Jun 03 23:56:38 BST 1997BeansBook.Simulator

Cooler

public class Cooler extends TemperatureModifier implements CoolingRequestListener, VetoableChangeListener

Fields Summary
Constructors Summary
public Cooler()

      // a cooler is a temperature modifier that operates at
      // 0 degress celsius
      super(0.0, "COOLER ON", "COOLER OFF",
               Color.cyan, Color.yellow);
   
Methods Summary
public voidcoolingRequest(ServiceRequestEvent evt)

     // set the Running property based on the value returned
     // by the isStart method from the event
     setRunning(evt.isStart());
   
public voidvetoableChange(java.beans.PropertyChangeEvent evt)

      // only interested in ComfortTemperature
      if (evt.getPropertyName().equals("ComfortTemperature"))
      {
         // get the proposed temperature
         Double d = (Double)evt.getNewValue();
 
         // veto a temperature under 0 degrees Celsius
         if (d.doubleValue() < 0.0)
         {
            throw new PropertyVetoException("Invalid Comfort Temperature", evt);
         }
      }