so going sound ridiculous working on project deliberately want slow down loading of image down loads line line. there anyway can this? have image in imagepane extension of jpanel:
public imagepane() { initcomponents(); image = null; //this.setautoscrolls(true); } public void setimage(string path) throws ioexception { image = imageio.read(getclass().getresource(path)); } @override public void paintcomponent(graphics g) { //graphics2d g2 = (grahpics2d)g; g.drawimage(image, 0,0, this); }
and in window i'm trying display as:
imagepane image = new imagepane(); try { image.setimage("netscapelogo2.png"); } catch (ioexception e) { system.out.print("failed set"); e.printstacktrace(); } //jscrollpane1.add(image); jscrollpane1.setviewportview(image);
i imagine need change paintcomponent method i'm not sure how that.
this solution uses premisse i simulate image loading line line uncovering gradually. – rodrigoap
image loaded @ once , displayed read line line!
a solution create thread , let thread work...
runnable r = new runnable(){ @override run(){ for(int = 0; < image.getheight(); i++){ // wait 100ms 'slow down' thread.sleep(100)// surround try/catch, may throw exception line = line + 1; //increase amount of visible lines repaint(); //update panel } } } //i don't know when want start animation new thead(r).start(); //so trigger @ free
when draw image draw amount of lines, not whole image @ all...
@override public void paintcomponent(graphics g) { super(g); int w = image.getwidth(); int h = image.getheight(); g.drawimage(image, 0,0, w, line, 0,0,w,h,this); }
the drawimage methode bit weird, see docu further help
of course need define private int line = 0;
@ place