
// Import the Table.
import COM.Subrahmanyam.table.*;

// Imort the AWT.
import java.awt.*;
import java.awt.event.*;

public class SampleTable extends Frame {
    
    private Table table;
    
    public SampleTable() {
	
	// Create a table with some size.
	table = new Table();
	table.setSize(300, 200);
	
	// Set some properties:
	table.showHorizontalSeparator(false); 
	table.showVerticalSeparator(true);    
	table.setHiliteMode(Table.HILITE_ROW);
	table.setClickMode(Table.DOUBLE_CLICK);
	table.setLineSpacing(1.25);            
	table.setFonts(new Font("Helvetica", Font.PLAIN, 12),
		       new Font("Helvetica", Font.PLAIN, 12));
	
	// Create some data to be added to the table.
	String column[] = {new String("Welcome"), 
			   new String("to the"), 
			   new String("demo")};
	
	// Let the title of the first column be "One". 
	//Add the column.
	table.addColumn("One", column);
	
	// Add another column.
	table.addColumn("Two", column);
	
	// Now add some rows.
	String row[] = {new String("Hi"), new String("There")};
	table.addRow(row);
	
	// Add listeners.
	table.addItemListener(new IL());
	table.addActionListener(new AL());
	
	// Now add the table to the frame.
	setLayout(new BorderLayout());
	add("Center", table);
    }

    // Set minimum size.
    public Dimension minimumSize() 
	{
	    return new Dimension(300, 200);
	}
    
    // Also set the preferred size.
    public Dimension preferredSize() 
	{
	    return minimumSize();
	}
    
    // The entry point.
    public static void main(String[] args) 
	{
	    SampleTable table = new SampleTable();
	    table.pack();
	    table.show();
	}
    
    // Listener to listen item events.
    class IL implements ItemListener 
    {
	public void itemStateChanged(ItemEvent ie) {
	    System.out.println(ie.toString());
	}
    }

    // Listener to listen action events.
    class AL implements ActionListener 
    {
	public void actionPerformed(ActionEvent ae) 
	    {
		System.out.println(ae.toString());
	    }
    }
    
    
}
