Java Code
import java.awt.*;
import javax.swing.*;
public class JTableData extends JApplet
{
String[ ] colHeadings = { "Name", "Sport", "Location", "Age" };
Object data[ ][ ] = { { "Liz", "Skiing", "Fort Fun", "21" },
{ "C. M.", "Cooking", "Denver", "56" },
{ "Oscar", "Mtn Biking","Mars", "19" },
};
JScrollPane scrollPane;
JTable table;
public void init( )
{
table = new JTable( data, colHeadings );
table.setPreferredScrollableViewportSize(new Dimension(400, 70));
//Create the scroll pane and add the table to it.
scrollPane = new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
}
}
©2006 by E.S.Boese. All Rights Reserved