Tuesday, October 19, 2010










/*This is a program used to produced My Star and 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;
import java.awt.Font;
import java.awt.color.ColorSpace;

public class Mystar extends JPanel{

 public void paint(Graphics g){
  super.paint(g);
 
  Graphics2D g2d = (Graphics2D)g;
  int x[]={55,67,109,73,83,55,27,37,1,43};
  int y[]={0,36,36,54,96,72,96,54,36,36};
  g2d.fillPolygon(x,y,10);

 }

 public static void main(String[] args){


  JFrame frame = new JFrame("My Star");
  frame.add(new Mystar());
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(300,200);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
 }
   }

No comments:

Post a Comment