/*
 * COPYRIGHT (c) 1998-1999 Jan-Henrik Haukeland, http://www.tildeslash.com/
 */


package ts.ui;

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

/**
 * A simple GridBagLayout Panel
 *
 * @author  Jan-Henrik Haukeland &lt;hauk@tildeslash.com&gt;
 * @version $Id: GBLPanel.java,v 1.7 1999/02/21 08:47:23 hauk Exp $
 */
public class GBLPanel extends JPanel
{
  // Anchors
  public final static int WEST= GridBagConstraints.WEST;
  public final static int EAST= GridBagConstraints.EAST;
  public final static int NORTH= GridBagConstraints.NORTH;
  public final static int SOUTH= GridBagConstraints.SOUTH;
  
  // Width/Height
  public final static int REST= GridBagConstraints.REMAINDER;

  // Make these public accessible
  public static GridBagLayout      gridbag;
  public static GridBagConstraints constraints;
  public static Insets             insets;
  

  public GBLPanel()
  {
    gridbag=     new GridBagLayout();
    constraints= new GridBagConstraints();
    insets=      new Insets(1,1,1,1);
    setLayout(gridbag);
  }

  
  public void add(Container ct, int x, int y, int w, int h) 
  {
    this.add( ct, x, y,  w,  h, GridBagConstraints.CENTER);
  }


  public void add(Container ct, int x, int y, int w, int h, int a) 
  {
    constraints.gridx= x; constraints.gridy= y; 
    constraints.gridwidth= w; constraints.gridheight= h; 
    constraints.insets= insets; constraints.anchor = a;

    gridbag.setConstraints(ct, constraints);
    this.add(ct);
  }

}
