我需要上传并显示用 .. 选择的图像JFileChooser
(即用户想要设置他/她的个人资料图片)JFrame
。我应该怎么做?
这是我选择文件的代码:
private void UploadImageActionPerformed(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();
}
}
}