View Single Post
  #2 (permalink)  
Old 03-26-2008, 08:07 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
import javax.swing.*; import javax.swing.table.*; public class Test { public static void main(String[] args) { Test test = new Test(); JTable table = new JTable(test.getModel()); JOptionPane.showMessageDialog(null, new JScrollPane(table), "", JOptionPane.PLAIN_MESSAGE); } private AbstractTableModel getModel() { return new AbstractTableModel() { // You must specify at least these 3 methods. // See comments in AbstractTableModel api. public int getRowCount() { return 10; } public int getColumnCount() { return 4; } public Object getValueAt(int row, int col) { return String.valueOf((row+1)) + (col+1); } }; } }
Reply With Quote