Java JTable set row height by row index

Description

Java JTable set row height by row index

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class Main {
   public static void main(String[] args) {
      JFrame f = new JFrame("JTable example");
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      Object[][] cellData = { { "1-1", "1-2" },// 
                              { "2-1", "2-2" } //
                            };//w  w  w .  j a v a  2 s .c  om
      String[] columnNames = { "col1", "col2" };

      JTable table = new JTable(cellData, columnNames);

      table.setRowHeight(1, 30);

      f.add(new JScrollPane(table));
      f.pack();

      f.setVisible(true);

   }
}



PreviousNext

Related