Hi friend,
I have one example of java which will demonstrate you the use of JTable class:
Code:
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class JTableDemo {
public static void main(String args[]) {
JFrame frp = new JFrame();
frp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },
{ "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
Object columnNames[] = { "Column One", "Column Two", "Column Three" };
JTable table = new JTable(rowData, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
frp.add(scrollPane, BorderLayout.CENTER);
frp.setSize(200, 150);
frp.setVisible(true);
}
Bookmarks