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

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

  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. 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. Abraham Khalil

    JTable and Resizing

    Abraham Khalil, Sep 8, 2003, in forum: Java
    Replies:
    0
    Views:
    724
    Abraham Khalil
    Sep 8, 2003
  2. James Gralton

    JTable resizing row/column cell header

    James Gralton, Jul 16, 2004, in forum: Java
    Replies:
    1
    Views:
    757
    Andrew Thompson
    Jul 16, 2004
  3. R^3
    Replies:
    0
    Views:
    1,331
  4. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    340
    Proper
    Apr 21, 2009
  5. Proper
    Replies:
    0
    Views:
    191
    Proper
    Apr 18, 2009
Loading...

Share This Page