Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- public class randCircle extends JPanel {
- private JFrame f;
- private JPanel p;
- public randCircle() {
- f = new JFrame("Bullseye");
- p = new JPanel();
- f.setBackground(Color.cyan);
- p.setPreferredSize(new Dimension(400, 400));
- }
- public void paint(Graphics g) {
- super.paint(g);
- g.setColor(Color.gray);
- g.fillOval(0, 0, 20, 20);
- }
- public void display() {
- f.add(p);
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- f.setVisible(true);
- f.pack();
- }
- }
- // Main Class
- public class randCircleMain {
- public static void main(String args[]) {
- randCircle panel = new randCircle();
- panel.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement