swing - Paint function will not iterate more than 3 times Java -
so every time run program , type 1 system, allow me move oval once,then program print debug 2 more times without moving oval. why?
import java.awt.graphics; import java.awt.graphics2d; import java.util.scanner; import javax.swing.jframe; /** * * @author admin */ public class testinggame extends jframe{ public scanner scan = new scanner(system.in); public static int x = 0; public static int y = 0; /** * @param args command line arguments */ public static void main(string[] args) { testinggame myframe = new testinggame(); myframe.setsize(1000,1000); myframe.setlocationrelativeto(null); myframe.setdefaultcloseoperation(myframe.exit_on_close); myframe.setvisible(true); } public void paint(graphics g){ update(g); } public void update(graphics g){ graphics2d ga = (graphics2d)g; ga.drawoval(x, y, 50, 50); int input = scan.nextint(); if(input == 1){ system.out.println("debug"); x = x + 100; y = y + 100; } } }
Comments
Post a Comment