import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class JGradientJavaExample extends JFrame
{
public void paint(Graphics gr)
{
super.paint(gr);
int x = 20, y = 40, x2 = 160, y2 = 80;
Graphics2D GR2D = (Graphics2D)gr;
GR2D.setPaint(new GradientPaint(x, y, Color.LIGHT_GRAY,
x2, y2, Color.DARK_GRAY, false));
GR2D.fill(new Rectangle2D.Double(x, y, x2, y2));
x = 200;
GR2D.setPaint(new GradientPaint(x, y, Color.LIGHT_GRAY,
x2, y2, Color.DARK_GRAY, true));
GR2D.fill(new Rectangle2D.Double(x, y, x2, y2));
}
public static void main(String[] gs)
{
JGradientJavaExample frm = new JGradientJavaExample();
frm.setSize(440,180);
frm.setVisible(true);
}
}
Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses