import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;

public class WComponent extends JComponent 
{
  private Dimension backgroundDimension;
  
  /**
   * Default Constructor
   */
  public WComponent()  
  {
  }

  public WComponent(JLayeredPane layers, int WIDTH, int HEIGHT)
  {
    backgroundDimension = new Dimension(WIDTH,HEIGHT);
    
    //********************************************************
    //Include the Canvas in the SRPole and set its layer
    //********************************************************
    
    layers.add(this);
    layers.setLayer(this,-1);
    
    //***********************************
    //Setup properties of the SRPole
    //***********************************
    
    //this.setForeground(Color.lightGray);
    this.setSize(backgroundDimension);
    this.setBounds(0,0,WIDTH,HEIGHT);
    
    //********************************
    //Set the Areas to a visible state
    //********************************
    
    this.setVisible(true);
  }

  public WComponent(JLayeredPane layers, Dimension bounds)
  {
    //********************************************************
    //Include the Canvas in the SRPole and set its layer
    //********************************************************
    
    layers.add(this);
    layers.setLayer(this,-1);
    
    //***********************************
    //Setup properties of the SRPole
    //***********************************
    
    //this.setForeground(Color.lightGray);
    this.setSize(bounds);
    this.setBounds(0,0,(int)bounds.getWidth(),(int)bounds.getHeight());
    
    //********************************
    //Set the Areas to a visible state
    //********************************
    
    this.setVisible(true);
  }

  public WComponent(JLayeredPane layers, BevelBorder bevel, Dimension bounds)
  {
    //********************************************************
    //Include the Canvas in the SRPole and set its layer
    //********************************************************
    
    layers.add(this);
    layers.setLayer(this,-1);
    
    //***********************************
    //Setup properties of the SRPole
    //***********************************
    
    //this.setForeground(Color.lightGray);
    this.setSize(bounds);
    this.setBounds(0,0,(int)bounds.getWidth(),(int)bounds.getHeight());
    this.setBorder(bevel);
    
    //********************************
    //Set the Areas to a visible state
    //********************************
    
    this.setVisible(true);
  }

  public WComponent(JLayeredPane layers, BevelBorder bevel, int WIDTH, int HEIGHT)
  {
    backgroundDimension = new Dimension(WIDTH,HEIGHT);
    
    //********************************************************
    //Include the Canvas in the SRPole and set its layer
    //********************************************************
    
    layers.add(this);
    layers.setLayer(this,-1);
    
    //***********************************
    //Setup properties of the SRPole
    //***********************************
    
    //this.setForeground(Color.lightGray);
    this.setSize(backgroundDimension);
    this.setBounds(0,0,WIDTH,HEIGHT);
    this.setBorder(bevel);
    
    //********************************
    //Set the Areas to a visible state
    //********************************
    
    this.setVisible(true);
  }

  public void paintComponent(Graphics g)
  {
    try
    {
      //refresh canvas
      g.setColor(Color.lightGray);
      g.fillRect(0,0,this.getWidth(),this.getHeight());
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
    
  }

  //Overloading the update function so the background is not redrawn
  public void update(Graphics g)
  {
    paint(g); 
  }
}
