Java Swing How to - Allow the User to Resize a Column in a JTable








Question

We would like to know how to allow the User to Resize a Column in a JTable.

Answer

//from  w  w  w . j a  v  a2  s  .  c  om

import javax.swing.JTable;

public class Main {
  public static void main(String[] argv) throws Exception {
    int rows = 3;
    int cols = 3;
    JTable table = new JTable(rows, cols);

    table.getTableHeader().setResizingAllowed(false);
  }
}