import javax.swing.*; import javax.swing.table.*; public class Test extends JFrame { public static void main(String args[]) { Test frame = new Test(); frame.setTitle("Swing表的例子"); frame.setBounds(300, 300, 450, 300); frame.setDefaultCloSEOperation(JFrame.DISPOSE_ON_CLOSE); frame.show(); } public Test() { TableModel model = new TestModel(); getContentPane().add(new JScrollPane(new JTable(model))); } private static class TestModel extends AbstractTableModel { final int rows = 100, cols = 10; public int getRowCount() { return rows; } public int getColumnCount() { return cols; } public Object getValueAt(int row, int col) { return "(" + row + "," + col + ")"; } } }