/*
 * GridPanel.java
 *
 * Created on 28. prosinec 2000, 20:44
 */

package timetable.gui;

/**
 *
 * @author  Administrator
 * @version 
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class GridPanel extends javax.swing.JPanel {
    TableLayout tableLayout;
    java.util.Vector removedComponents;
    

    /** Creates new GridPanel */
    public GridPanel(int rows, int cols) {
        super();
        
        tableLayout = new TableLayout(rows,cols);
        setLayout(tableLayout);
    }
    
    public void setRows(int rows) {
        tableLayout.setRows(rows);
    }

    public void setColumns(int cols) {
        tableLayout.setColumns(cols);
    }
    
    public void addComponent(Component component,Object constraints) {
        this.add(component,constraints);
    }
    
    public void removeComponent(Component component) {
        component.setVisible(false);
        tableLayout.removeLayoutComponent(component);
        removedComponents.add(component);
    }
    
    public void removeAllComponents() {
        while (tableLayout.getComponentCount()>0) 
            removeComponent(tableLayout.getComponent(0));
    }

}
