Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Rotating selected Swing JTable column headers?

Thread Tools

Rotating selected Swing JTable column headers?

Posts: n/a
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?

Reply With Quote
Posts: n/a
> > Anyone done this before?
> * * *TableColumn.setHeaderRenderer() sounds promising, although

Sure. I'm after something a bit more programmer-friendly like

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.
Reply With Quote
Posts: n/a
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.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SWING] Binding selected elements of a JList to a JTable loris_p Java 2 03-03-2008 01:52 PM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM