import org.eclipse.swt.widgets.FileDialog;
FileDialog dialog = new FileDialog(this.getShell(), SWT.NULL);
dialog.setFilterExtensions(new String[] { "*.txt", "*.*" });
dialog.setFilterNames(new String[] { "Text files", "All files" });
String path = dialog.open();
if (path != null) {
File file = new File(path);
if (file.isFile()) {
System.out.println(file.toString());
}
}
The snippet above filters by text files (*.txt) and all files (*.*) only, and it can be easily applied to any button or file menu option click event.
./M6