Friday, October 14, 2016

a program in java bean to implement simple properties of a bean.

Aim: write a program in java bean to implement simple properties of a bean.

Program:

package sunw.demo.Box;
import java.awt.*;
public class Box extends Canvas
{
   private int depth,height,width;
    public Box()
     {
        setSize(120,30);
        height=0;
        depth=0;
        width=0;
}
  public int getDepth()
   {
       return depth;
    }
   public void setDepth(int depth)
    {
       this.depth=depth;
    }
   public int getHeight()
   {
       return height;
    }
   public void setHeight(int height)
   {
       this.height=height;
    }
   public int getWidth()
   {
       return width;
    }
   public void setWidth(int width)
    {
        this.width=width;
    }
    public void paint(Graphics g)
    {
        double volume=(height*depth*width);
        String msg="Volume="+volume;
        g.drawString(msg,10,10);
     }
 }

Output:





Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home