//GUI
final JFrame ff=new JFrame();
final JButton b1=new JButton("Choose file");
final JLabel l1=new JLabel("Choosen file: ");
ff.setVisible(true);
ff.setSize(700, 500);
ff.getContentPane().setLayout(null);
b1.setBounds(300, 20, 100, 30);
l1.setBounds(300, 60, 80, 30);
ff.getContentPane().add(b1);
ff.getContentPane().add(l1);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
try{
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION)
{
//Convert the data into an image
Image i=ImageIO.read(new File((chooser.getSelectedFile().getPath())));
i=i.getScaledInstance(100, 100,i.SCALE_DEFAULT);
JLabel img= new JLabel(new ImageIcon(i));
img.setBounds(320, 90, 100, 100);
ff.getContentPane().add(img);
}
}catch(IOException IO){System.out.print("File not found");}
}});