954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Colspan and coloring a cell in jtable

Hello guys, Im new at java. Ive been googling this for hours but don't have any luck.
In HTML, there's this colspan thing wherein you merge two or more vertical cells. These cells become one. I want to know what's the syntax for that one in java. Also, I want to know how to set the background color of a cell in java. I've been googling for hours and all I saw was coloring columns and rows.

Whilliam
Junior Poster
112 posts since Oct 2008
Reputation Points: 19
Solved Threads: 0
 

AFAIK there's no sensible way to merge cells. The only work-around is to use a custom cell renderer and work out what to display in each of the individual cells so it looks like they are combined into one. - not easy or elegant, but possible.

Setting background color for individual cells is also a custom cell renderer thing, bit this time it's fairly straightforward.
http://download.oracle.com/javase/tutorial/uiswing/components/table.html#renderer

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You