Archived

This topic is now archived and is closed to further replies.

himifire

[java] help!!!!! repaint() method

Recommended Posts

himifire    122
in a case like the one i show below how do you use a repaint or paintimeddailty method?? theframe is a JFrame and ive tried with a canvas too. public static void UpdateBall() { boolean DO = false; while(!DO) { for(int x = 0; x < 1; x = x) Bx += Bxv; By += Byv; ballArea = new Rectangle(Bx, By, 5 + Bx, 5 + By); theframe.repaint(ballArea); g.setColor(Color.pink); g.drawOval(Bx, By, 5, 5); ballArea = new Rectangle(Bx, By, 5, 5);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Use theframe.repaint(Bx, By, 5 + Bx, 5 + By); I looked in the Component class and i did not found any version of repaint(java.awt.Rectangle). It might help.

Share this post


Link to post
Share on other sites
tortoise    122
there should be a repaint(Rectangle) though. Did you add it in your subclass?

What is the problem, it''s not repainting? The awt paint system is a passive painting system based on the OS''s repaint events. When you say repaint() that''s just a request to repaint, you can''t rely on it. In a game you almost always want active painting. Unless this is an applet or something, look into BufferStrategies and possibly the fullscreen api. That way you can ditch the awt paint system and paint exactly when you want to paint.

Share this post


Link to post
Share on other sites