gui animation problems
Hey. Thanks in advance
I am reading a book.... It told me to try and animate an oval with what i know(come up with a concept, but i decided to write code).
I'm making an oval that moves diagonally with a JPanel. It compiles perfectly, but doesn't run quite as expected.
I want to say my logic is correct, so I must be doing it totally wrong then.
class AnimatedB extends JFrame
public static void main(String args)
AnimatedB animate = new AnimatedB();
public void go()
frame = new JFrame();
ken = new Ken4Funny();
button = new JButton("animate");
class Ken4Funny extends JPanel implements ActionListener
int x = 20;
int plusx = 5;
int y = 50;
int plusy = 5;
public void paintComponent(Graphics g)
x += plusx;
y += plusy;
g.fillOval(x, y, 100, 100);
public void actionPerformed(ActionEvent event)
for(int xx = 0; xx <=20; xx++)
plusx += 5;
plusy += 5;
wow i just noticed the problem in my for loop lmao
still doesn't work though
Duplicate post. Answers are in other thread: http://www.java-forums.org/advanced-...el-button.html. I'm locking this one. OP, please avoid multiposting the same question more than once. Thank you for your cooperation.