How to display an image(all major formats), selected by JFileChooser in java
Posted
by
Tushar Maroo
on Stack Overflow
See other posts from Stack Overflow
or by Tushar Maroo
Published on 2012-06-02T20:59:31Z
Indexed on
2012/06/03
10:40 UTC
Read the original article
Hit count: 181
I am developing an image editing app, so want to display an image selected by JFileChooser
, so what would be best approach so that it can display all formats jpg
, png
, gif
etc. OpenButton
is used for invocation of filechooser.
private void OpenActionPerformed(java.awt.event.ActionEvent evt) {
int returnVal = fileChosser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fileChosser.getSelectedFile();
// What to do with the file
// I want code for this part
try {
//code that might create an exception
}
catch (Exception e1) {
e.printStackTrace();
}
}
}
© Stack Overflow or respective owner