java - read and jlabel set icon a image with different extension .001 -
file file = new file("c:\\registro_sql\\imagens\\livro02\\0000\\000011.001"); bufferedimage bufferedimage = null; try { bufferedimage = imageio.read(file); icon icon = (icon) bufferedimage; lblimageicon.seticon(icon); } catch (ioexception ex) { joptionpane.showmessagedialog(null, "erro!"); }
error:
exception in thread "main" java.lang.error: unresolved compilation problem: unhandled exception type ioexception @ certidoesorganizado.executor.main(executor.java:6)
i have files extesion .001, .002, .003, files image, cant rename since software use they, want use java display images files, idea since bufferedimage not showing nothing, retunr error
the error has nothing code in question shows ioexception
has try/catch
block. error produced code not shown.
also statement
icon icon = (icon) bufferedimage;
will result in classcastexception
bufferedimage
not icon
type.
replace
lblimageicon.seticon(icon);
with
lblimageicon.seticon(new imageicon(bufferedimage));
Comments
Post a Comment