java - How can I draw an image part by part? -
class drawima extends jpanel{ protected void paintcomponent(graphics g) { super.paintcomponent(g); (int i=0;i<20;i++){ (int j=0;j<20;j++) { g.drawimage(buarr[i*20+j], 20*i, 20*j, 20, 20, null); try { thread.sleep(10); } catch (interruptedexception e) { e.printstacktrace(); } } } } } in part, buarr 400 blocks divided bufferedimage , want them draw 1 one, method can not draw blocks separately, how can this? swing single thread , not thread safe. this means should not perform long running or blocking ( thread.sleep ) operations within iu thread (the event dispatching thread). means can not update, modify or create ui elements outside of edt context. instead, use swing timer generate repeated callback @ specified interval , render portions of image bufferedimage , can paint component via paintcompon...