FileDocCategorySizeDatePackage
ThermostatBeanInfo.javaAPI DocExample1234Wed Jun 04 00:05:28 BST 1997BeansBook.Simulator

ThermostatBeanInfo.java

// This example is from the book Developing Java Beans by Robert Englander. 
// Copyright (c) 1997 O'Reilly & Associates.
// You may study, use, modify, and distribute this example for any purpose.
// This example is provided WITHOUT WARRANTY either expressed or implied.

// Chapter 9 -- The ThermostatBeanInfo class

package BeansBook.Simulator;

import java.beans.*;

public class ThermostatBeanInfo extends SimpleBeanInfo
{
   // return the bean descriptor
   public BeanDescriptor getBeanDescriptor() 
   {
      // create the bean descriptor
      BeanDescriptor bd = new BeanDescriptor(Thermostat.class);
      
      // set the display name
      bd.setDisplayName("Simulated Thermostat");
      
      // return the object
      return bd;
   }

   // get an icon
   public java.awt.Image getIcon(int iconKind)
   {
      // we're only supporting 16x16 color icon
       if (iconKind == BeanInfo.ICON_COLOR_16x16) 
       {
          // load the thermostat.gif file
          java.awt.Image img = loadImage("thermostat.gif");
          
          // return the image
          return img;
       }
       
       // return null for all other icon formats
       return null;
   }
}