package test; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; public class TableExample extends JFrame { public TableExample() { //headers for the table String[] columns = new String[] { "Id", "Name", "Hourly Rate", "Part Time" }; //actual data for the table in a 2d array Object[][] data = new Object[][] { {1, "John", 40.0, false }, {2, "Rambo", 70.0, false }, {3, "Zorro", 60.0, true }, }; //create table with data JTable table = new JTable(data, columns); //add the table to the frame this.add(table); this.setTitle("Table Example"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); this.setVisible(true); System.out.println("RO " + table.getRowHeight(0)); System.out.println("R1 " + table.getRowHeight(1)); System.out.println("R2 " + table.getRowHeight(2)); System.out.println("HEIGHT " + table.getHeight()); System.out.println("INTERCELL " + table.getIntercellSpacing()); System.out.println("MARGIN " + table.getRowMargin()); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new TableExample(); } }); } }