Tue Nov 11, 2008 6:12 pm
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
public class EffectsOfStroke extends JPanel{
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
double p = 12, q = 45, width = 65, height = 65;
Rectangle2D rectangle = new Rectangle2D.Double(p, q, width, height);
GradientPaint gradientPaint= new GradientPaint(65, 65, Color.red,
90, 90,Color.cyan, true);
g2d.setPaint(gradientPaint);
g2d.fill(rectangle);
rectangle.setFrame(p + 90, q, width, height);
g2d.setPaint(gradientPaint);
g2d.setStroke(new BasicStroke(10));
g2d.draw(rectangle);
rectangle.setFrame(p + 180, q, width, height);
g2d.setPaint(Color.black);
g2d.draw(rectangle);
}
public static void main(String[] args) {
JFrame frame = new JFrame("Show Effect");
frame.getContentPane().add(new EffectsOfStroke());
frame.setSize(350, 200);
frame.show();
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.