Advertisement
Guest User

Untitled

a guest
Mar 24th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Dimension;
  3. import java.awt.Graphics;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JPanel;
  7.  
  8. public class randCircle extends JPanel {
  9.     private JFrame f;
  10.     private JPanel p;
  11.  
  12.     public randCircle() {
  13.         f = new JFrame("Bullseye");
  14.         p = new JPanel();
  15.  
  16.         f.setBackground(Color.cyan);
  17.         p.setPreferredSize(new Dimension(400, 400));
  18.     }
  19.  
  20.     public void paint(Graphics g) {
  21.         super.paint(g);
  22.         g.setColor(Color.gray);
  23.         g.fillOval(0, 0, 20, 20);
  24.     }
  25.  
  26.     public void display() {
  27.         f.add(p);
  28.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29.         f.setVisible(true);
  30.         f.pack();
  31.     }
  32. }
  33.  
  34. // Main Class
  35.  
  36. public class randCircleMain {
  37.     public static void main(String args[]) {
  38.         randCircle panel = new randCircle();
  39.         panel.display();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement