public void paint(Graphics g) {
// TODO 自动生成的方法存根 int h=400; int pix[]=new int[w*h]; int dex=0; for(int i=0;i<h;i++){ int red=(i*255)/(h-1); for(int y=0;y<w;y++){ int blue=(y*255)/(w-1); pix[dex++]=(255<<24)|(red<<16)|blue; } } ImageProducer ip=new MemoryImageSource(w, h, pix, 0, w); Image img=createImage(ip); g.drawImage(img, 0, 0, this); }