Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ColorTable Array!!

 
Justin bob
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I'm doing a color table array, it displays 100x20 rectangles(256 of them) with 256 shades of green, blue, or red. My name is printed in the very top left had rect. and the rest are also numbered.

im having a problem getting all the numbers to show up...
here is my code....

if anyone can help, i would appreciate it.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not very familiar with applets, but I shall have a go.

Actually when I tried running your code, the numbers appeared nice and clear in yellow, but I couldn't see the coloured rectangles; the whole background was black. Why are you using the same identifier for your class as your Color[] array? Use a different name, to avoid confusion.

You don't need the several for loops; you can combine them into one, and it is a good idea not to use a number in the middle. Also you don't need to use i as a field, so you get:




BUT you don't really nead Rcolor Bcolor or Gcolor at all.
You can simplify it to something on the lines of

You do realise that the first three colours will be completely black, and there will be no green or blue to them until no 33? In fact the brightest colour will be (85, 7, 7), which is about the same colour as a bar of plain chocolate. Is that what you intended?

In your paint() method, why have you get x and y? You don't actually seem to use them. You don't seem to use h and w, either. Can you get rid of them?
And you seem to be setting one of them to i%32. Why?

I am not quite sure what you are doing with the rectangles; they seem to be falling off the right side of the view.

Try what I have suggested, and see whether that makes it any better.

CR
[ November 07, 2005: Message edited by: Campbell Ritchie ]
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you get it to work?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic