Created
August 15, 2017 14:09
-
-
Save ajitid/53c6a6a287e28db6cbff6326a32041c9 to your computer and use it in GitHub Desktop.
Basic Applet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.applet.*; | |
public class applet extends Applet implements Runnable { | |
String str; | |
int x,y; | |
Thread th; | |
public void init() { | |
str = "I like to move it move it"; | |
x = y = 5; | |
th = new Thread(this); | |
th.start(); | |
} | |
public void run() { | |
while (true) { | |
y=x+=5; | |
try { | |
Thread.sleep(500); | |
} | |
catch(Exception e) | |
{ | |
System.out.println(e); | |
} | |
repaint(); | |
} | |
} | |
public void paint(Graphics g) { | |
g.drawString(str, x, y); | |
} | |
} | |
/* | |
<applet code="applet.java" height=600 width=600></applet> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment