View Single Post
  #1 (permalink)  
Old 06-04-2008, 10:09 AM
MrPickle's Avatar
MrPickle MrPickle is offline
PT Admin
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 332
iTrader: (0)
MrPickle is a jewel in the roughMrPickle is a jewel in the roughMrPickle is a jewel in the rough
Java programs not showing

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(00200100);
        
g.setColor(Color.black);
        
g.drawString("Sample Applet"2020);
        
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>

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote