static String[] headers = { "Name", "Surname", "Telephone" };
static String[][] data = {
{ "John", "Smith", "1112221" },
{ "Ivan", "Black", "2221111" },
{ "George", "White", "3334444" },
{ "Bolvan", "Black", "2235111" },
{ "Serg", "Black", "2221511" },
{ "Pussy", "Black", "2221111" },
{ "Tonya", "Red", "2121111" },
{ "Elise", "Green", "2321111" },
};
static JTable myTable;
myTable = new JTable(data, headers);
frame.add(myTable);
public class MyTable {
public static String[] headers = { "Name", "Surname", "Telephone" };
public static Object[][] data = {
{ "John", "Smith", "1112221" },
{ "Ivan", "Black", "2221111" },
{ "George", "White", "3334444" },
{ "Bolvan", "Black", "2235111" },
{ "Serg", "Black", "2221511" },
{ "Pussy", "Black", "2221111" },
{ "Tonya", "Red", "2121111" },
{ "Elise", "Green", "2321111" },
};
public static JTable myTable;
public MyTable() {
myTable = new JTable(data, headers);
myTable.setFillsViewportHeight(true);
JScrollPane scrollPane = new JScrollPane(myTable);
JFrame frame = new JFrame();
frame.add(scrollPane);
frame.pack();
frame.setVisible(true);
}
}