This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi, I need to set some kind of background pattern (like dots,cross) for cells that are inactive.I was using lightGray color to do the same......but I want to color those cells and wish to have a different background to show that these are disabled. Any suggestions are welcome. Thanks Pomchi
Rob Ross
Bartender
Joined: Jan 07, 2002
Posts: 2205
posted
0
You'll need to create a custom TableCellRenderer and install on your table columns so that you can override the cell component's paint() method to do your custom background pattern drawing. Rob
Rob
SCJP 1.4
Pomchi Bedi
Ranch Hand
Joined: Apr 03, 2001
Posts: 55
posted
0
Hi Rob, I know that this is how I can put an icon in the cell.But I want my pattern to occupy the entire cell space.It should increase or decrease with the cell width. Any example related to this would help. Thanks Pomchi [ January 09, 2002: Message edited by: Pomchi Bedi ]
Here's a quick example to do what you want... look especially at the PatternRenderer class... that defines the behaivior you want...
-Nate
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Pomchi Bedi
Ranch Hand
Joined: Apr 03, 2001
Posts: 55
posted
0
Hi Nate, Thanks so much for your help. But I have one more problem.All my rows have different background colors and in each row there are a few cells that are inactive/disabled.I want the background color of those inactive cells to be the same as the other ones in the row but along with the background color I want the background pattern to appear for the diasbled cells. That means I want to change the background of the imageIcon I am rendering.Is it possible?? Thanks & Regards Pomchi
If you use images for your ImageIcons that support transparency (like Gifs) then yes, you can... you'll also need to call super.paintComponent( g ) in the first line of your PatternRenderer paintComponent() method. If you don't want to make image files, you can always just extend Icon and draw the image you need in it's paintIcon() method...