public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setPaint(new java-awt.GradientPaint(0F, 0F, new Color(255, 255, 255), (float)getSize().getWidth(), (float) getSize().getHeight(), new java.awt.Color(0, 0, 0)));
g.fillRect(0, 0, (int)getSize().getWidth(), (int)getSize().getHeight());
}
public class GradPanel extends JPanel{
Color c1;
Color c2;
public GradPanel(Color c1, Color c2) {
this.c1 = c1;
this.c2 = c2;
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setPaint(new GradientPaint(
0,
0,
c1,
(float)getSize().getWidth(),
(float) getSize().getHeight(),
c2)
);
g.fillRect(0, 0, (int)getSize().getWidth(), (int)getSize().getHeight());
}
}