Skip to content

Commit dad2cf1

Browse files
committed
added applets
1 parent 345712d commit dad2cf1

File tree

9 files changed

+342
-0
lines changed

9 files changed

+342
-0
lines changed

Applets/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Applets/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Applets/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Applets/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Applets/.idea/workspace.xml

Lines changed: 259 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Applets/Applets.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
568 Bytes
Binary file not shown.
1.58 KB
Binary file not shown.

Applets/src/myApplet.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import java.applet.Applet;
2+
import java.awt.Color;
3+
import java.awt.Graphics;
4+
class Ball {
5+
int x,y,radius,dx,dy;
6+
Color BallColor;
7+
public Ball(int x,int y,int radius,int dx,int dy,Color bColor) {
8+
this.x=x;
9+
this.y=y;
10+
this.radius=radius;
11+
this.dx=dx;
12+
this.dy=dy;
13+
BallColor=bColor;
14+
}
15+
}
16+
public class myApplet extends Applet implements Runnable{
17+
Ball redBall;
18+
public void init() {
19+
redBall=new Ball(150,0,20,2,5,Color.red);
20+
Thread t = new Thread(this);
21+
t.start();
22+
}
23+
public void paint(Graphics g) {
24+
g.setColor(redBall.BallColor);
25+
g.fillOval(redBall.x, redBall.y, redBall.radius, redBall.radius);
26+
}
27+
public void run() {
28+
try {
29+
Color c = redBall.BallColor;
30+
redBall.BallColor = new Color(c.getRed(), c.getBlue()+20, c.getGreen());
31+
redBall.y=redBall.y+redBall.dy;
32+
}
33+
catch(Exception e){}
34+
while(redBall.BallColor.getBlue()!=255) {
35+
try {
36+
displacementOperation(redBall);
37+
Thread.sleep(1000);
38+
repaint();
39+
}
40+
catch(Exception e){}
41+
}
42+
}
43+
public void displacementOperation(Ball ball) {
44+
Color c = ball.BallColor;
45+
ball.BallColor = new Color(c.getRed(), c.getBlue()+20, c.getGreen());
46+
ball.y=ball.y+ball.dy;
47+
}
48+
}

0 commit comments

Comments
 (0)