Two Laptop Bag
The moose likes Swing / AWT / SWT and the fly likes JTable Format Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Format Question" Watch "JTable Format Question" New topic

JTable Format Question

Michael Cocchi

Joined: Nov 29, 2004
Posts: 2
Good Morning,

I have a JTable with 14 number/string columns.
Every other row or thereabouts I want to simply display a sentence that may take up the length of an entire row.

so basically I want the text in the first cell in a row to be able to span the length the whole row if necessary. (like in excel)

Is this possible?

Michael Cocchi

Joined: Nov 29, 2004
Posts: 2
After wasting a whole day researching, I have found that my only hope may lie in creating a custom TableCellRenderer. I have done so but have not found a way to lengthen the cell width. I can do all kinds of fun stuff to the cells but not length the width.

Please remember that I want custom column widths by row.

Any help?
raoul schmidiger

Joined: Feb 15, 2005
Posts: 4

i got the same problem. there doesn't seem to be an easy answer to this. one guy once managed, but he tweaked the standard lib quite a bit.

i am now going to do it like this: i take a table with one column. when i want to put a row in, that spans all columns, i add a label, when there should be more than one cell, i add another table in the cell of the outer table.

should be easy.

regards raoul
I agree. Here's the link:
subject: JTable Format Question
It's not a secret anymore!