JTable column sizing

Discussion in 'Java' started by Daniel Luis dos Santos, Feb 10, 2010.

  1. Hello,

    I have a JTable with some columns. I am setting the widths of some
    columns to some preferred size. One column has no header text, and the
    cells have a check box. I want the cells of that column to have the
    least amount of extra width around the check boxes. I set the preferred
    size on the table column to be 1 or 0 and the there is always space
    around the check boxes. Is it possible to remove that extra space. I
    have the same problem on some other columns.

    Those columns on which I am setting the width, I am also setting them
    not to be resizable. But when I resize the window (and thus the table),
    the non-resizable columns also resize proportionally. Can I tell them
    to be fixed size no matter what width the table has ?

    Thanks.
    Daniel Luis dos Santos, Feb 10, 2010
    #1
    1. Advertising

  2. In article <4b71f7ca$0$1900$>,
    Daniel Luis dos Santos <> wrote:

    > I have a JTable with some columns. I am setting the widths of some
    > columns to some preferred size. One column has no header text, and
    > the cells have a check box. I want the cells of that column to have
    > the least amount of extra width around the check boxes. I set the
    > preferred size on the table column to be 1 or 0 and the there is
    > always space around the check boxes. Is it possible to remove that
    > extra space. I have the same problem on some other columns.
    >
    > Those columns on which I am setting the width, I am also setting them
    > not to be resizable. But when I resize the window (and thus the
    > table), the non-resizable columns also resize proportionally. Can I
    > tell them to be fixed size no matter what width the table has ?


    You could override the check box's paintBorder() method or change the
    borderPainted property.

    <http://java.sun.com/javase/6/docs/api/javax/swing/AbstractButton.html>

    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
    John B. Matthews, Feb 10, 2010
    #2
    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. Tivo Escobar
    Replies:
    1
    Views:
    7,314
    manusa
    Apr 12, 2007
  2. Replies:
    1
    Views:
    619
    Winista
    Jun 1, 2006
  3. Tintin92
    Replies:
    1
    Views:
    1,697
    Andrew Thompson
    Feb 14, 2007
  4. -Alex

    DataGrid Column sizing - Help

    -Alex, Aug 30, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    160
    Jeffrey Tan[MSFT]
    Sep 8, 2004
  5. Haircuts Are Important
    Replies:
    3
    Views:
    318
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page