tags:

views:

197

answers:

1

How to adjust the size and colour of grid in JTable and how to set JTable so that length of column or row can be increased and decreased by dragging it?

A: 

You can use setGridColor to set the color of the grid.

To let the user adjust column width, use getTableHeader().setResizingAllowed(true).

There is no out-of-the-box support for resizing rows, this post could help.

Some more information:

    // grid color
    jTable1.setGridColor(Color.BLUE);

    // columns resizable
    jTable1.getTableHeader().setResizingAllowed(true);

    // initial width of column 1
    jTable1.getColumnModel().getColumn(1).setPreferredWidth(400);

    // height of al columns
    jTable1.setRowHeight(50);

    // height of column 2
    jTable1.setRowHeight(2, 25);
Peter Lang