import javax.swing.*; import javax.swing.table.*; import java.awt.*; public class CellGap{ JTable table; public static void main(String[] args) { new CellGap(); } public CellGap(){ JFrame frame = new JFrame("Setting the margin in JTable Component!"); JPanel panel = new JPanel(); String data[][] = {{"Vinod","Computer","3"},{"Rahul","History","2"},{"Manoj","Biology","4"},{"Sanjay","PSD","5"}}; String col [] = {"Name","Course","Year"}; DefaultTableModel model = new DefaultTableModel(data,col); table = new JTable(model); Dimension dim = new Dimension(20,1); table.setIntercellSpacing(new Dimension(dim)); SetRowHight(table); table.setColumnSelectionAllowed(true); JTableHeader header = table.getTableHeader(); header.setBackground(Color.yellow); JScrollPane pane = new JScrollPane(table); panel.add(pane); frame.add(panel); frame.setSize(500,150); frame.setUndecorated(true); frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public void SetRowHight(JTable table){ int height = table.getRowHeight(); table.setRowHeight(height+10); } }