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. Advertisements

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. AndrewF
    Replies:
    1
    Views:
    1,052
    Bruce Barker
    Oct 10, 2005
  2. gajo
    Replies:
    2
    Views:
    27,789
    Pacific Guy
    Jun 25, 2004
  3. hilz
    Replies:
    0
    Views:
    3,670
  4. Christian-Josef Schrattenthaler

    JTable and optimal column width.

    Christian-Josef Schrattenthaler, Jul 23, 2006, in forum: Java
    Replies:
    2
    Views:
    2,453
    IchBin
    Jul 23, 2006
  5. Cal
    Replies:
    1
    Views:
    681
    Tim B
    Jan 8, 2007
  6. ssk
    Replies:
    5
    Views:
    6,436
    Jukka K. Korpela
    Oct 30, 2006
  7. sonaljain
    Replies:
    0
    Views:
    1,248
    sonaljain
    Mar 16, 2011
  8. Carl Howarth

    DG Column Width vs Table Column Width

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