Hola, me llamo la atencion tu post y puse a probar un poco, te falto un parametro para el constructor de GradientPaint
g2.setPaint(new GradientPaint(0.0f, 0.0f, color1.darker(),getWidth(),getHeight(), color2.darker()));
import java.awt.*;
import javax.swing.*;
public class NuevoJpanel
extends JPanel{ protected void paintComponent
(Graphics g
){ float x=getWidth();
float y=getHeight();
g2.
setPaint(new GradientPaint(0.0f, 0.0f, color1.
darker(),getWidth
(),getHeight
(), color2.
darker())); g2.fillRect(clip.x, clip.y, clip.width, clip.height);
}
public Color getColor1
() {return color1
;} public void setColor1
(Color color1
) {this.
color1 = color1
;} public Color getColor2
() {return color2
;} public void setColor2
(Color color2
){this.
color2 = color2
;} public static void main
(String[] args
){ NuevoJpanel panel = new NuevoJpanel();
panel.setVisible(true);
ventana.add(panel);
ventana.setVisible(true);
}
}
le agregue el main solo para probarlo
Funciona bien creo que es lo que necesitas
Saludos