r/javahelp • • May 25 '15

Please help me, my animation wont work

    TestAnimation_pkg;

public class TestAnimation_Class extends Applet{ //

import java.applet.Applet; import java.awt.*; // import java.util.Timer; import java.util.TimerTask;

	int x=0
	int y=0;			//
	int z=0;

	 
	public void init(){
	        int delay = 250; // delay for 1/4 sec.
	        int period =   ; // repeat every 0.25 sec.
	        Timer timer = new Timer();
	        TimerTask task = new TimerTask() {
	            int count = 0;
	            public void run() {
	                System.out println("doing");		//
	                Toolkit.getDefaultToolkit().beep();	//
	                repaint();
	                count++;
	                if (count == 0){		//
	                    cancel();
	                }
	            }
	        };
	        timer.scheduleAtFixedRate(task, delay, period);
	}
	 
	public void stop(){}

public void paint(Graphics g){
	x=x+4;				//
	y=y-4;
	 
	g.setColor(Colour.red)	//
	 
	g.fillRect(x, ?, 50, 50);	//
	 
	}

	 

	}				//
0 Upvotes

3 comments sorted by

-3

u/jacob-akse May 25 '15

is someone going to help me?

1

u/TheHorribleTruth Kind of meh May 25 '15

How about you read the posting rules in the sidebar first? You know, for instance the parts about

  • using a descriptive title

  • describing the problem that you're having

  • and last but not least: how to format your code properly

1

u/[deleted] May 25 '15

There are a few issues with your code

  • importing should happen outside (before) your class declaration.

  • Missing semicolons

  • period is not assigned any value

  • incomplete call to println

And a few more. It looks sloppy mate, please fix up simple mistakes that your compiler tells you about and come back with properly formatted code.