java - How to show Image in Panel using button press action -


i want show image on panel press button. create code

jbutton btnnewbutton = new jbutton("next");     btnnewbutton.addactionlistener(new actionlistener() {         public void actionperformed(actionevent arg0) {             if(i<files1.length){                 bufferedimage bi;                 try {                     bi = imageio.read(new file(""+files1[i]));                     system.out.println(files1[i]);                     jlabel label = new jlabel(new imageicon(bi));                     panel_1.add(label);                     panel_1.repaint();                 } catch (ioexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 }             }             else                 system.out.println("end of picture");             i++;         }     }); 

but after click button image doesn't show.

but after click button image doesn't show.

looks missing revalidate(). basic code when adding component visible gui is:

panel.add(....); panel.revalidate(); // invoke layout manager panel.repaint(); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -