import javax.swing.*;
import java.awt.event.*;
public class JFileChooser_Test extends JFrame implements ActionListener
{
JButton jButton1 = new JButton("ļ");
     JButton jButton2 = new JButton("ļ");
     JFileChooser jFileChooser1 = new JFileChooser();
     JLabel jLabel1 = new JLabel("ѡļΪ");
     JScrollPane jScrollPane1 = new JScrollPane();
     JTextArea jTextArea1 = new JTextArea();
     public JFileChooser_Test()
     {
        setLayout(null);
        setTitle("ļԻӦ");
        jButton1.setBounds(30, 26, 120, 41);
        jButton2.setBounds(33, 80, 119, 38);
        jLabel1.setBounds(33, 110, 140,40);
        jScrollPane1.setBounds(34, 150, 115, 58);
        jFileChooser1.setBounds(198, 316, 172, 88);
        jScrollPane1.getViewport().add(jTextArea1);
        add(jButton1);
        add(jButton2);
        add(jFileChooser1);
        add(jLabel1);
        add(jScrollPane1);
        jButton1.addActionListener(this);
        jButton2.addActionListener(this);
        setBounds(200, 200, 500, 250);
        validate();
        setVisible(true);
    }    
    public void actionPerformed(ActionEvent e)
    {
        if(e.getSource()==jButton1)
        {
        	int n = jFileChooser1.showOpenDialog(this);
            String filename = jFileChooser1.getSelectedFile().toString();
            if (n == JFileChooser.APPROVE_OPTION)
            {
            	jTextArea1.append(filename);
            }
        }
        else
        {
        	int n = jFileChooser1.showSaveDialog(this);
            String filename = jFileChooser1.getSelectedFile().toString();
            if (n == JFileChooser.APPROVE_OPTION)
            {
            	jTextArea1.append(filename);
            }
        }        
    }
}
class JFileChooser_Test_jButton1_actionAdapter
{
public static void main(String args[])
    {
        JFileChooser_Test ta = new JFileChooser_Test();
    }
}
