يمكن وضع هذا الكود فى فرام وعمل برنامج كامل
مع كامل تحياتى
حسام
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.util.Hashtable;
import java.util.Enumeration;
class imageviewer extends JFrame {
JFileChooser fc=new JFileChooser("c:");
ImageIcon img;
JLabel l;
imageviewer()
{
int x=fc.showOpenDialog(this);
String filepath="";//put intial value to it because it intialize in the if statment
//and the if can be false so u would ever enter it
if(x==JFileChooser.APPROVE_OPTION)
{
filepath=fc.getSelectedFile().getPath();
}
img=new ImageIcon(filepath);
l=new JLabel(img);
Container c=getContentPane();
c.add(l);
setSize(200,200);
setVisible(true);
}
public static void main(String[] args)
{
new imageviewer();
}
}