/* Filter File Type with FileDialog in java */
public void actionPerformed(ActionEvent e)
{
FileDialog saveFileDialog = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
saveFileDialog.setFilenameFilter(new FilenameFilter()
FileDialog saveFileDialog = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
saveFileDialog.setFilenameFilter(new FilenameFilter()
{
public boolean accept(File dir, String name)
public boolean accept(File dir, String name)
{
return name.endsWith(".jpg") || name.endsWith(".jpeg");
}
});
saveFileDialog.setFile("Untitled.jpg");
saveFileDialog.setVisible(true);
}
or use
saveFileDialog.setFile("*.jpg");
return name.endsWith(".jpg") || name.endsWith(".jpeg");
}
});
saveFileDialog.setFile("Untitled.jpg");
saveFileDialog.setVisible(true);
}
or use
saveFileDialog.setFile("*.jpg");