java - Timer implement error -
i have error timer, , don't know error situated in code.
error:
exception in thread "main" java.lang.error: unresolved compilation problems: constructor timer(int, player) undefined method start() undefined type timer
at player.(player.java:12)
at game.main(game.java:11)
import java.awt.graphics; import java.awt.graphics2d; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.geom.ellipse2d; import java.util.timer; import javax.swing.*; public class player extends jpanel implements actionlistener{ timer t = new timer(5, this); // error (line 12) double x = 0; double velx = 2; double y = 0; double vely = 2; public void paintcomponent(graphics g){ super.paintcomponent(g); graphics2d g2 = (graphics2d) g; ellipse2d circle = new ellipse2d.double(x,y,40,40); g2.fill(circle); t.start(); // error } public void actionperformed(actionevent e){ x += velx; y += vely; repaint(); } }
you've imported java.util.timer
. maybe meant javax.swing.timer
?
you can google more info, here pretty explanation of difference between two.
Comments
Post a Comment