hey iam writing this code in button's actionPerformed but it doesn't displaying any image . Can you identify what is problem in it???
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("Images","jpeg", "jpg", "JPG", "JPEG", "gif","GIF", "png","PNG");
chooser.setFileFilter(filter);
if (chooser.showOpenDialog(this)== JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
ImageIcon icon = new ImageIcon(file.getName());
imagePanel.add(new JLabel(icon));
}