HI
   Maybe you can  reload JFileChooser's approveSelection()  method.and check whether 
file exits  and popup a  alert dialog.the following is a simple sample:


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;


public class test extends JApplet{
        JFileChooser chooser=new file();
        public void init(){
                JButton button=new JButton("SAVE");

                JDialog dialog;
                getContentPane().add(button,BorderLayout.CENTER);
                button.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                                chooser.showSaveDialog(null);

                        }
                });
        }

        public static void main(String[] args){
                JFrame f=new JFrame();
                JApplet applet=new test();
                applet.init();
                f.setContentPane(applet.getContentPane());
                f.setBounds(100,100,500,500);
                f.setVisible(true);
        }
}

class file extends JFileChooser{
         public void approveSelection() {
                File tt=getSelectedFile();
                if(tt.exists()){
                        JOptionPane.showMessageDialog(null,"File exists!");
                        return;
                }
                super.approveSelection();
         }
}


Good Luck
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to