Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes ColorTable Array!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ColorTable Array!!" Watch "ColorTable Array!!" New topic
Author

ColorTable Array!!

Justin bob
Greenhorn

Joined: Nov 07, 2005
Posts: 3
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

Joined: Oct 13, 2005
Posts: 36453
    
  15
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

Joined: Oct 13, 2005
Posts: 36453
    
  15
Did you get it to work?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ColorTable Array!!
 
Similar Threads
Problem painting component
Null Pointer Exception Error - .contains(p)
Why does it not show the new coordinates?!!??!!
Getting the TwoButtons to add the gradient circle to the panel
Colour picker, MouseDown(Event, int x, int y) Depreciation Help!