Set column width in JTable?

Discussion in 'Java' started by Rene Ruppert, Oct 17, 2003.

  1. Rene Ruppert

    Rene Ruppert Guest

    Hi,

    I'm trying to set the column width in a JTable.
    This only works on the first column.
    As soon as I use setMinWidth() or setMaxWidth() on the second or third
    column setPreferredWidth() wont't work at all.

    I use this funtion:
    public void insertHead(String headName, int width)
    {
    TableColumn column = new TableColumn();
    column.setHeaderValue(headName);
    columnModel.addColumn(column);
    column.setMinWidth(15);
    column.setMaxWidth(200);
    column.setPreferredWidth(width);
    }

    The JTable is set to AUTO_RESIZE_SUBSEQUENT_COLUMNS.

    Any hints?

    Thanks.

    Rene
     
    Rene Ruppert, Oct 17, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gajo
    Replies:
    2
    Views:
    27,331
    Pacific Guy
    Jun 25, 2004
  2. hilz
    Replies:
    0
    Views:
    3,404
  3. Cal
    Replies:
    1
    Views:
    555
    Tim B
    Jan 8, 2007
  4. sonaljain
    Replies:
    0
    Views:
    1,128
    sonaljain
    Mar 16, 2011
  5. Carl Howarth

    DG Column Width vs Table Column Width

    Carl Howarth, Oct 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    293
    Eliyahu Goldin
    Oct 24, 2004
Loading...

Share This Page