import javax.swing.*; import javax.swing.table.*; import java.awt.*; public class TestTableGrid { JFrame fr; public TestTableGrid() { fr = new JFrame("Test Table Grid"); TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10;} public Object getValueAt(int row, int col) { return new Integer(row*col); } }; DefaultTableCellRenderer r = new DefaultTableCellRenderer(); r.setOpaque(true); r.setBackground(Color.YELLOW); JTable t = new JTable(dataModel); t.setDefaultRenderer(Object.class, r); t.setGridColor(Color.BLACK); t.setShowGrid(true); t.setShowHorizontalLines(true); t.setShowVerticalLines(true); fr.setContentPane(t); fr.setLocation(200, 200); fr.pack(); fr.setVisible(true); } public static void main(String args[]) { new TestTableGrid(); } }