Run a method only once in paint () (Java) -


im trying run method once when call in paint () method, when call runs on , over. example:

private void somemethod () {  system.out.println ("success"); } @override public void paintcomponent (graphics g) {  somemethod ();  repaint (); } 

this output "success" forever, can output once.

i think should write same bridge

try this:

public class someclass{     private boolean hasdone = false;     public void paintcomponent(graphics g){         super.paintcomponent(g);         if(!hasdone){             somemethod();             hasdone = true;         }     } } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -