bufferstrategy - Java buffer strategy sometimes doesn't draw properly -


i created game in java uses buffer strategy. white frame or white border. happens every fifth time. searched lot can't figure out i'm doing wrong. code compiles , there aren't errors printed out.

if if fails, frame looks example that:

white border

completely white frame

here's code (only relevant parts):

private bufferstrategy bs; public testclass(){     setresizable(false);     setsize(1000,600);     setdefaultcloseoperation(jframe.exit_on_close);     setignorerepaint(true);     setvisible(true);     createbufferstrategy(2);     bs = getbufferstrategy(); }  protected void paint() {     {         graphics2d g=null;         try {             g = (graphics2d) bs.getdrawgraphics();             g.setcolor(color.cyan);             g.fillrect(0, 0, this.getwidth(), this.getheight());         } {             g.dispose();         }         bs.show();     } while (bs.contentslost()); }  public static void main(string[] args) {     testclass window = new testclass();     window.paint(); } 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -