• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

color in jtable cell

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
case solved
had to zero the blue parameter:

myLightBlue.PNG
the ibm efect
[Thumbnail for myLightBlue.PNG]
 
Rob Camick
Ranch Hand
Posts: 2565
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the advices
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic