Column resizing problem in JTable

Discussion in 'Java' started by AimsLife, Sep 12, 2007.

  1. AimsLife

    AimsLife Guest

    Hi,

    I am using jdk1.5 kit for development. I developed a JFrame window
    which has JTable in view. JTable columns and rows created using Custom
    "TableModel" with the name of "InfoTableModel" extended by
    "AbstractTableModel". InfoTableModel contain list of data to be
    display. I need customize my table column, can you please guide me how
    I can give column width for proper column width?

    Regards,
    -aimslife
     
    AimsLife, Sep 12, 2007
    #1
    1. Advertisements

  2. AimsLife wrote:
    > Hi,
    >
    > I am using jdk1.5 kit for development. I developed a JFrame window
    > which has JTable in view. JTable columns and rows created using Custom
    > "TableModel" with the name of "InfoTableModel" extended by
    > "AbstractTableModel". InfoTableModel contain list of data to be
    > display. I need customize my table column, can you please guide me how
    > I can give column width for proper column width?


    JTable table;
    int column, width;
    ....
    table.getColumnModel().getColumn(column).setPreferredWidth(width);

    Usually I have the table in a JScrollPane in a layout that allows it to
    resize to the max size allowed by window size & other components. In
    this case the preferred widths of the columns is used to set the widths
    of the columns RELATIVE to one another. As a rule of thumb I set the
    width to 10 x the number of characters I expect the column to contain.
     
    RedGrittyBrick, Sep 12, 2007
    #2
    1. Advertisements

  3. AimsLife

    AimsLife Guest

    Thanks

    Regards,
    -aimslife

    On Sep 12, 11:37 pm, RedGrittyBrick <>
    wrote:
    > AimsLife wrote:
    > > Hi,

    >
    > > I am using jdk1.5 kit for development. I developed a JFrame window
    > > which has JTable in view. JTable columns and rows created using Custom
    > > "TableModel" with the name of "InfoTableModel" extended by
    > > "AbstractTableModel". InfoTableModel contain list of data to be
    > > display. I need customize my table column, can you please guide me how
    > > I can give column width for proper column width?

    >
    > JTable table;
    > int column, width;
    > ...
    > table.getColumnModel().getColumn(column).setPreferredWidth(width);
    >
    > Usually I have the table in a JScrollPane in a layout that allows it to
    > resize to the max size allowed by window size & other components. In
    > this case the preferred widths of the columns is used to set the widths
    > of the columns RELATIVE to one another. As a rule of thumb I set the
    > width to 10 x the number of characters I expect the column to contain.
     
    AimsLife, Sep 13, 2007
    #3
    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. Abraham Khalil

    JTable and Resizing

    Abraham Khalil, Sep 8, 2003, in forum: Java
    Replies:
    0
    Views:
    875
    Abraham Khalil
    Sep 8, 2003
  2. Tivo Escobar
    Replies:
    1
    Views:
    8,852
    manusa
    Apr 12, 2007
  3. James Gralton

    JTable resizing row/column cell header

    James Gralton, Jul 16, 2004, in forum: Java
    Replies:
    1
    Views:
    881
    Andrew Thompson
    Jul 16, 2004
  4. R^3
    Replies:
    0
    Views:
    1,767
  5. Tintin92
    Replies:
    1
    Views:
    2,134
    Andrew Thompson
    Feb 14, 2007
  6. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    596
    Proper
    Apr 21, 2009
  7. Proper
    Replies:
    0
    Views:
    338
    Proper
    Apr 18, 2009
  8. Haircuts Are Important
    Replies:
    3
    Views:
    957
    Haircuts Are Important
    Jun 4, 2013
Loading...