aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes color in jtable cell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "color in jtable cell" Watch "color in jtable cell" New topic
Author

color in jtable cell

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i have this code (to be entirely frank i cant recall where i found it), that paints every other line with a diferent color


my Q is: how do i change this (light gray) color to a more light blue color?


java amateur
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

miguel lisboa wrote:my Q is

http://faq.javaranch.com/java/UseRealWords
For non-native English users it might not be clear that with "Q" you mean "question".

how do i change this (light gray) color to a more light blue color?

By increasing the blue value of the new Color perhaps?

Moving to Swing / AWT.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
sorry for the Q

well, i think i tried, but the result is identical to what i had before:



anyway, in this field i feel like a blind man trying to see with his hands ...
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
case solved
had to zero the blue parameter:




[Thumbnail for myLightBlue.PNG]

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
anyway, in this field i feel like a blind man trying to see with his hands ...


That is exactly how we feel since we don't know what you are trying to accomplish.

The default background color is WHITE. Are you trying to make the background color a light shade of blue? Then why don't you just hardcode the value you want the color to be?

What if somebody changes the background color to RED? Are you trying to change the color to a lighter/darker shade of red, or are you still trying to use a lighter/darker shade of blue.

Try your code with other background colors and see what happens. Then maybe you can give a more direct requirement because if you goal is simply to make the alternate color blue, then just hardcode the value and create the Color object once in the constructor of your class so you don't create new Color objects every time a cell is rendered.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
thanks for the advices
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

Rob Camick wrote:What if somebody changes the background color to RED? Are you trying to change the color to a lighter/darker shade of red, or are you still trying to use a lighter/darker shade of blue.

For the former there are methods brighter() and darker() in Color.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: color in jtable cell