Tuesday, October 19, 2010
/*This is a program used to produce a CAR and a g2d.fillPolygon() is a method.*/
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TransparentRectangles3 extends JPanel
{
public void paint (Graphics g)
{
super.paint(g);
Graphics2D g2d=(Graphics2D)g;
g2d.setColor(Color.BLUE);
// for (int i=1; i <= 10; i++)
{
// g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,i * 0.1f)
g2d.setColor(Color.BLUE);
int x[]={300,600,700,800,800,300,300};
int y[]={200,200,300,300,400,400,200};
g2d.fillPolygon(x,y,7);
g2d.fillOval(400,350,100,100);
g2d.fillOval(700,350,100,100);
g2d.setColor(Color.GREEN);
g2d.fillOval(425,375,50,50);
g2d.fillOval(725,375,50,50);
}
}
public static void main(String[]args)
{
JFrame frame =new JFrame("Transparent Rectangles");
frame.add(new TransparentRectangles3());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(590,120);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment