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
Post a Comment