Gradients

Gradients: You can create many different kinds of gradients. You can create vertical, horizontal, or diagonal gradients. You can also create special gradients (for instance a box-shaped gradient which blends from a small red box in the center to a large blue box around the edges of the applet area).

HERE'S THE CODE: public Image makeImage(int w, int h) { int pixels[] = new int[w*h]; int index = 0; for(int y=0; y<h; y++) { int red = (y*255) / (h-1); for(int x=0; x<w; x++) { int blue = (x*255)/(w-1); pixels[index++] = (255<<24) | (red << 16) | blue; } } return createImage(new MemoryImageSource(w,h,pixels,0,w)); }