Login    New User    Forgot Password    Help      

Table

Java Tutorials

Example

// Table
import java.awt.*;
import javax.swing.*;

 

public class swing8 extends JApplet
{

public void init()
{

Container contentPane = getContentPane();

contentPane.setLayout(new BorderLayout());

final String[] colHeads = { "Name", "Phone", "Fax"};

final Object[][] data =
{
{"Gail", "4567", "8675"},
{"Ken", "7566", "3333"},
{"Ed", "9999", "1313"},
};
JTable table = new JTable(data,colHeads);

 

int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

JScrollPane jsp = new JScrollPane(table, v,h);

contentPane.add(jsp,BorderLayout.CENTER);
}
}

 

Output

Java Tutorials