i try to choose image file from JFilechooser to open on a label ,but i still can't open any image T__T is there any worng in my code
this is the function that use to chooser file:
public void OpenImage(){
JFileChooser fc = new JFileChooser();
fc.setMultiSelectionEnabled(false);
fc.addChoosableFileFilter(new ImageFilter());
fc.setFileView(new imageFileView());
fc.setAccessory(new imagePreview(fc));
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = fc.showOpenDialog(this);
if(returnVal == JFileChooser.CANCEL_OPTION)
{ file = null; }
else
{ file = fc.getSelectedFile();}
}/*end OpenImage*/
and i took the file value to the other function ,it's in the same class .
/********************************/
/*label for image*/
/********************************/
String ImgName = file.getPath();
ImgName = file.toString();
ImgName = ImgName.replace('\\','/');
Image image = Toolkit.getDefaultToolkit().getImage(ImgName);
ImageIcon Img = new ImageIcon(image);
JLabel photoLabel = new JLabel(Img);
photoLabel.setIcon(Img);
JPanel photoPanel = new JPanel();
photoPanel.add(photoLabel);
tell me pleasse what's worng with me
thanks for every help