Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void paintComponent(Graphics g)
- {
- super.paintComponent(g);
- Graphics2D g2d = (Graphics2D) g;
- for(Ball ball : this.balls)
- {
- ball.draw(g2d);
- }
- g2d.dispose();
- }
- @Override
- public void run()
- {
- while(true)
- {
- try
- {
- Thread.sleep((long) (1000.0/60.0));
- } catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- repaint(); // This lags when moving mouse
- // while the code below does not
- // Graphics g = getGraphics();
- // Graphics2D g2d = (Graphics2D) g;
- // for(Ball ball : this.balls)
- // {
- // ball.draw(g2d);
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment