java - Image IO Write not writing -


basically trying save image have edited in jframe, have menu save item , have action listener set save item , works fine, file chooser comes , can select save it, thing when hit save, not there. here code, missing something?

 if(e.getsource().equals(save)){         jfilechooser keep = new jfilechooser();         keep.setselectedfile(new file ("newimage.jpg"));         filenameextensionfilter  filters = new filenameextensionfilter("jpeg", "jpg");         keep.setfilefilter(filters);         file output = keep.getselectedfile();          int count = keep.showsavedialog(keep);         bufferedimage out = filteredimage;          if (count == jfilechooser.cancel_option){          }         else{             try{                 imageio.write(out, "jpg", output);                  //i put here see if reaching method                 system.out.println("writing method");             }catch(exception d){             }         }     } 

so, reference selectedfile...

file output = keep.getselectedfile(); 

the show dialog...

int count = keep.showsavedialog(keep); bufferedimage out = filteredimage; 

then try , save image...

imageio.write(out, "jpg", output); 

...wait, what?! assuming getselectedfile isn't null, how know you're saving image?

that process should reversed slightly...

showsavedialog if (accepted) {     savefile = getselectedfile     imageio.write(img, "jpg", savefile); } 

as basic psudo code example


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -