jPanel, printing colours (int)

Hi, I have an array of ints which represent an image and i want to display them as blocks of colour on a jpanel. I have looked through the docs, but I can't seem to make anything work!

My array pixelMap[]

,-8232397,-14798523,-4668741,-11453661,-13676685,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1256524,-9206366,-1,-4418443,-5782302,0

My jpanel...

JPanel panel =new JPanel(new GridLayout(7,5));

Dimension e =new Dimension(40,40);

for (int y = 0; y < 35; y++){

JPanel z =new JPanel();

z.setPreferredSize(e);

z.setBackground(?) );

panel.add(z);

}

JFrame f =new JFrame();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.getContentPane().add(panel);

f.pack();

f.setLocationRelativeTo(null);

f.setVisible(true);

Thanks, Ron

[1203 byte] By [cakea] at [2007-11-27 2:11:57]
# 1
Check out BufferedImage on how you can construct an image with the right coloring type and set the data.
tjacobs01a at 2007-7-12 2:05:44 > top of Java-index,Java Essentials,Java Programming...
# 2
I don't want to construct a bufferedImage, I want to set the colour value of a jpanel so that I can display the downsampled image! Is there a way to pass an int value to the jpanel so that you can set the background color?Thanks
cakea at 2007-7-12 2:05:44 > top of Java-index,Java Essentials,Java Programming...
# 3

In the future, Swing related questions should be posted in the Swing forum.

> Is there a way to pass an int value to the jpanel so that you can set the background color?

No. You use a Color object to set the background color of a component. Read the Color API for the various methods of creating a Color object using int values.

camickra at 2007-7-12 2:05:44 > top of Java-index,Java Essentials,Java Programming...
# 4
Sorry, I will endeavour to put them in the right place, i just find it a little confusing for a beginner.Why is it, when you import java.awt.* you still have to import java.awt.color for it to work?And yes the color(int rgb) worked great.Many thanks, Ron
cakea at 2007-7-12 2:05:44 > top of Java-index,Java Essentials,Java Programming...