SHARE
TWEET

fen3

DulcetAirman Feb 23rd, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.Graphics;
  2. import java.awt.Color;
  3. import java.awt.Event;
  4.  
  5. public class fen3 extends java.applet.Applet {
  6.  
  7.     final int MAXSPOTS = 10;
  8.     int xspots[] = new int[MAXSPOTS];
  9.     int yspots[] = new int[MAXSPOTS];
  10.     int currspots = 0;
  11.  
  12.     public void init() {
  13.         setBackground(Color.white);
  14.     }
  15.  
  16.     public boolean mouseDown(Event evt, int x, int y) {
  17.         if (currspots < MAXSPOTS)
  18.             addspot(x, y);
  19.         else
  20.             System.out.println("Too many spots.");
  21.         return true;
  22.     }
  23.  
  24.     void addspot(int x, int y) {
  25.         xspots[currspots] = x;
  26.         yspots[currspots] = y;
  27.         currspots++;
  28.         repaint();
  29.  
  30.     }
  31.  
  32.     public void paint(Graphics g) {
  33.         g.setColor(Color.blue);
  34.         for (int i = 0; i < currspots; i++) {
  35.             g.fillOval(xspots[i] - 10, yspots[i] - 10, 20, 20);
  36.         }
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top