I created an interface and I\'d like to add a function that allows user to open a file. I\'m using AWT. I don\'t understand how to use FileDialog. Can you please give me an
To add to the answer by @TheBronx - for me, fd.setFile("*.txt");
is not working on OS X. This works:
fd.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".txt");
}
});
Or as a fancy Java 8 lambda:
fd.setFilenameFilter((dir, name) -> name.endsWith(".txt"));