Posts which you will also like.

Monday, November 29, 2010

Program in Java to print the bull's eye

Program in java to print the bull's eye

// Programmed by : Rajeev Mishra
// email          : rajeevmshr661@gmail.com

import java.awt.Graphics;
import javax.swing.JFrame;
import java.awt.Color;
import java.util.Random;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
class drawBulleye extends JPanel
{
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        Random r=new Random();
        for(int i=0;i<20;i++)
        {
            Color clr=new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255));
            g.setColor(clr);
            g.fillOval(10+5*i,10+5*i,200-10*i,200-10*i);
        }
    }
}
class Bulleye
{
    public static void main(String args[])
    {
        drawBulleye panel=new drawBulleye();
        JFrame app=new JFrame();
        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        app.add(panel);
        app.setSize(230,250);
        app.setVisible(true);
    }
}

No comments:

Post a Comment

Your comment may wait for moderation....

DMCA.com Protected by Copyscape Online Plagiarism Tool