Rotating selected Swing JTable column headers?

Discussion in 'Java' started by softwarepearls_com, Sep 6, 2008.

  1. I'd like to achieve the above so that I can have lots of columns (with
    Boolean cells) that have wide header titles.

    Ideally, the headers could be rotated a full 90 degrees, from pure
    horizontal (default) to pure vertical.

    Looked around in JTable/JTableHeader javadocs, and googled around the
    place, but couldn't find anything.

    Anyone done this before?
     
    softwarepearls_com, Sep 6, 2008
    #1
    1. Advertising

  2. > > Anyone done this before?
    >
    >      TableColumn.setHeaderRenderer() sounds promising, although


    Sure. I'm after something a bit more programmer-friendly like
    setHeaderAngle(double) ;-)

    I'm probably looking for something that JTable was never conceived to
    do, because, for the tilted headers to work, their shapes would have
    to distort from the rectangular to sheared rects, ie diamonds. For the
    last column, this poses a problem whereby the header needs to be wider
    than the natural width of the column.

    Don't think the Swing team ever considered the need to support this,
    but sure would be nice to be able to do.
     
    softwarepearls_com, Sep 6, 2008
    #2
    1. Advertising

  3. FYI, I managed to get acceptable-looking results by ditching the "any
    angle" idea, and just going for 90 degree rotation. The approach I
    took is to create a TableCellRenderer that uses JLabel's Icon-
    rendering functionality. I use narrow Icons holding the column
    titles.. resulting JTable looks good, and lets me have lots of very
    narrow columns.

    Thx for the suggestion though.
     
    softwarepearls_com, Sep 7, 2008
    #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. vishnu
    Replies:
    1
    Views:
    1,234
    Patrick.O.Ige
    Mar 25, 2006
  2. Tivo Escobar
    Replies:
    1
    Views:
    7,434
    manusa
    Apr 12, 2007
  3. Tintin92
    Replies:
    1
    Views:
    1,758
    Andrew Thompson
    Feb 14, 2007
  4. loris_p
    Replies:
    2
    Views:
    1,275
  5. Haircuts Are Important
    Replies:
    3
    Views:
    364
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page