Skip to main content
gamedev.net
🔒 Locked

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

Started by himifire Aug 10, 2003 at 9:39 AM 1 replies 350+ views
Original Post
himifire
himifire
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);
___________ DADDY LONG LEGZ HERE! novice java programmer :-)feel free to email me or my SN for AIM is JHHIM
tortoise
tortoise
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.