Download this source file


// A trivial JavaBean, just a rectangle with a single Property
// called "myColor".
//
// Written April 2000 by Wayne Pollock, Tampa Florida USA

package mybeans;

import java.awt.*;
import java.io.*;

public class SimpleBean extends Canvas implements Serializable
{
   private Color myColor;

   public SimpleBean ()
   {
      myColor = Color.white;
      setBackground( myColor );
   }

   public Color getMyColor () { return myColor; }
   public void setMyColor ( Color c )  { myColor = c; }

   public void paint ( Graphics g )
   {
      g.setColor( myColor );
      g.fillRect( 0, 0, getSize().width, getSize().height );
   }

   public Dimension getPreferredSize () { return new Dimension( 50, 50 ); }

   public Dimension getMinimumSize () { return getPreferredSize(); }
}