JTable column size

Discussion in 'Java' started by moongeegee, Sep 19, 2007.

  1. moongeegee

    moongeegee Guest

    I have a table contains many columns. One of columns contains
    checkbox. I have tried the following code to set the size, but the
    size is still too big. Please advise. Thanks.

    table.getColumnModel.getColumn(4).setPreferredWidth(5);
    or

    table.getColumnModel.getColumn(4).setPreferredWidth(1); <== the
    smallest number I can set.
    moongeegee, Sep 19, 2007
    #1
    1. Advertising

  2. moongeegee

    Roedy Green Guest

    On Wed, 19 Sep 2007 17:04:37 -0000, moongeegee <>
    wrote, quoted or indirectly quoted someone who said :

    >I have a table contains many columns. One of columns contains
    >checkbox. I have tried the following code to set the size, but the
    >size is still too big. Please advise. Thanks.


    Perhaps the problem is that JCheckBox has a label, and some space to
    separate the label from the label. I take it you have an empty label?

    I take it by "checkbox" you really mean JCheckBox.

    To get it smaller, I think you will have to create your own label-less
    component, cannibalising or overriding the JCheckBox code, and writing
    a custom cell renderer.

    You might even be able to do it simply with setPreferredSize
    setMaximumSize to chop off the label.

    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Sep 25, 2007
    #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. Gerhard Rapp

    Adjust column widths of JTable

    Gerhard Rapp, Jul 18, 2003, in forum: Java
    Replies:
    0
    Views:
    2,178
    Gerhard Rapp
    Jul 18, 2003
  2. Tivo Escobar
    Replies:
    1
    Views:
    7,268
    manusa
    Apr 12, 2007
  3. Tintin92
    Replies:
    1
    Views:
    1,672
    Andrew Thompson
    Feb 14, 2007
  4. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,529
    Michael Jung
    May 25, 2008
  5. Haircuts Are Important
    Replies:
    3
    Views:
    297
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page