/*
 *  =================================================================
 *  DemoTableData.java : In this applet, data in an array-of-arrays is
 *  used to populate the cells of a table. A String array stores the
 *  column headings.
 * 
 *  Adapted from : Pantham S., Pure JFC Swing, 1999.
 *  Modified by : Mark Austin                             March, 2001
 *  =================================================================
 */

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

public class DemoTableData extends JApplet {

    // 1. Create an array of names to be displayed in the table
    //    header.

    String[] columnNames = {"Name", "Size (Bytes)", "Date", "Directory"};

    // 2. Create an array of row data (each row is an array) to be
    //    displayed in the rows of the table.

    Object[][] rowData = {
        {  "AUTOEXEC.BAT",   "149", "09-11-98", new Boolean(false)},
        {          "REAL",   "DIR", "12-11-97", new Boolean(true)},
        {       "WINDOWS",   "DIR", "03-24-97", new Boolean(true)},
        {   "COMMAND.COM", "92879", "07-11-97", new Boolean(false)}};

    public void init() {

        // 3. Create a table by using the row and column data.

        JTable table = new JTable(rowData, columnNames);

        // 4. Add the table column header and the
        //    table to the content pane of the applet.

        getContentPane().add(table.getTableHeader(), BorderLayout.NORTH);
        getContentPane().add(table);
    }
}
