Graphics2D g2 = (Graphics2D)g;GradientPaint paint = new GradientPaint(0,0,Color.red,100,100,Color.yellow);g2.setPaint(paint);g.fillRect(0,0,100,100);