Adjust column widths of JTable

Discussion in 'Java' started by Gerhard Rapp, Jul 18, 2003.

  1. Gerhard Rapp

    Gerhard Rapp Guest

    Hi all.

    I try to automatically adjust the column widths of a JTable according to
    their content. My ideas were (1) to search the longest entry for each column
    by going through all entries. (Which is pretty slow for long tables) And (2)
    to adapt the getValueAt function to detect and store the longest entry for
    each column, so I can set these values when the table is displayed the first
    time. Btw. which event handler will I have to use here?

    I guess some of you have faced this problem before. What are your solutions?

    In this context I have another question? If the sum of the column widths is
    greater than the width of the table's scroll pane one has to set the
    autoresize strategy property of the table to OFF. If the total width is less
    than the scroll panes' width one gets an annoying border around the table.
    How can I prevent this? Apart from adding a dummy column at the right. And
    what about the rows?

    Thanks
    Gerhard
     
    Gerhard Rapp, Jul 18, 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. Replies:
    1
    Views:
    20,482
    Eliyahu Goldin
    Jul 26, 2006
  2. Daniel Luis dos Santos

    Making JTable column widths obey me

    Daniel Luis dos Santos, Feb 15, 2010, in forum: Java
    Replies:
    2
    Views:
    610
    John B. Matthews
    Feb 16, 2010
  3. Martin Gregorie

    How can I set column widths in a JTable

    Martin Gregorie, Oct 25, 2010, in forum: Java
    Replies:
    7
    Views:
    1,679
    Martin Gregorie
    Oct 27, 2010
  4. Greg P.

    ItemStyle.Width doens't adjust the size of a column?

    Greg P., Mar 28, 2007, in forum: ASP .Net Web Controls
    Replies:
    14
    Views:
    356
    Paul Shapiro
    Feb 11, 2008
  5. Replies:
    1
    Views:
    207
    Nathan Sokalski
    Apr 12, 2007
Loading...

Share This Page