display browsed image in jswing
<p>I want to get a contact image and display it in an imageview.I am Using eclipse.User browses an image and it should get displayed in an icon.Please help with the code.
I tried the below code.Its not displaying actual image..</p>

<pre><code>final JButton button = new JButton("New button");
        button.setBounds(459, 103, 89, 43);
        panelBgImg.add(button);

        JButton btnNewButton = new JButton("Browse");
        btnNewButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {

                 final JFileChooser fc = new JFileChooser();
                  int r = fc.showOpenDialog(getParent());

                  fc.setFileSelectionMode(fc.FILES_AND_DIRECTORIES);

                  if (r == JFileChooser.APPROVE_OPTION) {
                  String name = fc.getSelectedFile().getAbsolutePath();


                  File f = new File(name);
                  Icon icon = fc.getIcon(f);
                  button.setIcon(icon); 
                  }
            }
        });
</code></pre>
