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));
        }

Can you make a small complete program that compiles, executes and shows the problem?

Does the code tell the container that the JLabel is added to that it needs to do a new layout of its contents?

file.getName() just returns the file name - any path info is lost. So unless the file happened to be in the current working directory it won't get found just from the name. You could try getting the full path & name to identify the file fully, eg file.getCanonicalPath() rather than just file.getName()