Hello friend,
First i understand your problem, then i found solution for crash as wel as trick (**).
1)when user type ** then one dailog box will be appear front then give message to you , your are using trick ** and dnot use this
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
public class
Test implements ActionListener {
public static void main(
String args[]){
JFrame jf = new JFrame("FileChooser");
final JFileChooser jfc = new JFileChooser();
jfc.setAcceptAllFileFilterUsed(false);
FileNameExtensionFilter filter = new FileNameExtensionFilter(".html & .htm", ".html");
jfc.setFileFilter(filter);
jf.add(jfc);
//File f = jfc.getSelectedFile();
jfc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
File file = jfc.getSelectedFile();
String type = jfc.getTypeDescription(file);
System.out.println("File youfile chose type is"+ type);
if(type.equals(".html"))
{
}
else
{
JOptionPane.showMessageDialog(null, "please dont use trick **");
}
}
catch(Exception ioe)
{
}
}
});
//
//System.out.println("File you chose type is"+ type);
jf.setSize(300, 300);
jf.setVisible(true) ;
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}}