All pastes #465883 Raw Edit

Untitled

public text v1 · immutable
#465883 ·published 2007-04-30 17:49 UTC
rendered paste body
import java.applet.*;
import java.awt.*;
import java.applet.Applet;

public class proodos2 extends Applet implements Runnable {

    Thread the_thread;
    int move01=200;
    int x,y;
    
    Image image;	// The image that is currently being painted on the screen

    public void init() {
	setBackground(Color.gray);
    }
	
    public void start() {
	count=0;
	Thread the_thread=new Thread(this);
	the_thread.start(); 
    }
	
    public void stop() {
	the_thread=null; 
    }

    public void paint(Graphics g) {
	g.drawImage(image,x,y,200,200,this); 
    }

    public void run() {
	moveFromTop("photo01.jpg");
    }
    
    private void moveFromTop(String imagename) {
	image = getImage(getCodeBase(),imagename);	// update the image variable
	
	count=0;
	x=0;
	y=0;
	
    	while (count<move01) {
	    count++;
	    
	    if ( y == 100 ) {
		y = 400;
		setBackground(Color.black); 
	    }

	    y++;
	    repaint();

	    try { the_thread.sleep(30); } catch(InterruptedException e) { showStatus("aborted"); 
	    }
	}
    }
}