I am trying to test out Java but for some reason, my applets won't show in the web page and I don't know why.
Here's the code:
PHP Code:
import java.applet.*;
import java.awt.*;
public class SampleApplet extends Applet implements Runnable
{
int PosX = 10;
int PosY = 10;
int Radius = 20;
public void Init(){
setBackground(Color.blue);
}
public void Start(){
final Thread th = new Thread(this);
th.start();
}
public void Stop(){ }
public void Destroy(){ }
public void run(){
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while(true)
{
PosX++;
repaint();
try
{
Thread.sleep(20);
}
catch (final InterruptedException ex)
{
}
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}
public void Paint(Graphics g){
g.setColor(Color.white);
g.fillRect(0, 0, 200, 100);
g.setColor(Color.black);
g.drawString("Sample Applet", 20, 20);
g.setColor(Color.blue);
}
}
Here's the html code:
HTML Code:
<html> <body> <p><applet code = "SampleApplet.class" width = "500" height = "500" /></p> </body> </html>