Skip to content

Instantly share code, notes, and snippets.

@ajitid
Created August 15, 2017 14:09
Show Gist options
  • Save ajitid/53c6a6a287e28db6cbff6326a32041c9 to your computer and use it in GitHub Desktop.
Save ajitid/53c6a6a287e28db6cbff6326a32041c9 to your computer and use it in GitHub Desktop.
Basic Applet
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