home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacPeople 1998 #2
/
MACPEOPLE-1998-NO2.ISO
/
おまけ
/
ジャバジャバ工作教室
/
第6回
/
MPPApplet6.java
< prev
Wrap
Text File
|
1997-09-22
|
1KB
|
53 lines
import java.awt.*;
import java.util.Random;
public class MPPApplet6 extends java.applet.Applet {
int XX,YY,X1,Y1,RX,RY;
Color myC;
Random myR;
public void start() {
myR = new Random ();
}
public void update (Graphics g) {
paint (g);
}
public void paint (Graphics g) {
g.setColor (Color.black);
g.fillRect (0,0,400,300);
g.setColor (myC);
g.fillOval (XX,YY,RX,RY);
}
public boolean mouseUp (Event evt,int x,int y) {
X1 = myR.nextInt () % 10;
Y1 = Math.abs (myR.nextInt ()) % 10 + 5;
RX = 10;
RY = 10;
myC = Color.red;
for (int i = 1; i<=20; i++) {
XX = 200 + (X1 * i);
YY = 300 - (Y1 * i);
repaint ();
try {Thread.sleep (50);}
catch (InterruptedException e) {}
}
for (int i = 1; i<=10; i++) {
myC = new Color (myR.nextInt());
RX = RX + 10;
RY = RY + 10;
XX = XX - 5;
YY = YY - 5;
repaint ();
try {Thread.sleep (50);}
catch (InterruptedException e) {}
}
XX = -1000;
YY = -1000;
repaint ();
return true;
}
}