Results 1 to 2 of 2
Thread: My animation flickers.
- 05-17-2010, 07:38 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 10
- Rep Power
- 0
My animation flickers.
I'm trying to draw an animation but for some reason, it flickers.
Here is my code:
Java Code:package pong; import java.awt.Color; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.RepaintManager; import javax.swing.Timer; public class Field extends JFrame{ Timer timer; Ball ball = new Ball(200, 200); public Field() { setTitle("Pong"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 400); setVisible(true); getContentPane().setBackground(Color.WHITE); new Timer(100, new ActionListener() { public void actionPerformed(ActionEvent e) { ball.update(); repaint(); } }).start(); } @Override public void paint(Graphics g) { super.paint(g); ball.draw(g); } }
- 05-17-2010, 09:20 PM #2
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
Similar Threads
-
Animation with Animated GIF
By JavaBean in forum Java 2DReplies: 3Last Post: 06-04-2011, 04:26 PM -
need help about animation ?
By h9h in forum Java 2DReplies: 1Last Post: 10-30-2009, 11:41 AM -
JTextArea Animation
By hoglu in forum New To JavaReplies: 1Last Post: 12-18-2008, 11:44 AM -
Animation Applet
By Unome in forum Java AppletsReplies: 7Last Post: 10-17-2008, 07:34 AM -
GUI Animation
By serfster in forum New To JavaReplies: 2Last Post: 06-11-2008, 03:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks