home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacPeople 1998 #2
/
MACPEOPLE-1998-NO2.ISO
/
おまけ
/
ジャバジャバ工作教室
/
第5回
/
MPPApplet5.java
< prev
Wrap
Text File
|
1997-08-29
|
726b
|
39 lines
import java.awt.*;
import java.util.Random;
public class MPPApplet5 extends java.applet.Applet{
int XX,YY,RNum,flg;
Font myFont;
Random myR;
public void start() {
myFont = new Font ("Courier",Font.BOLD,36);
myR = new Random ();
XX = -100;
YY = -100;
RNum = 50;
flg = -5;
}
public void paint (Graphics g) {
g.setFont (myFont);
Color myC = new Color (myR.nextInt());
g.setColor (myC);
g.fillOval (XX,YY,RNum,RNum);
g.setColor (Color.red);
g.drawString ("Random Colors.",30,100);
}
public boolean mouseMove (Event evt,int x,int y) {
RNum = RNum + flg;
if ((RNum >= 50) | (RNum <= 0)) {
flg = flg * -1;
}
XX = x - RNum / 2;
YY = y - RNum / 2;
repaint ();
return true;
}
}