I think what you're looking for is the SWT's FileDialog , here is a example that clarifies its use a bit, in your case I understand that you want to use it to" Open "no for "Save" and I guess to handle several files, so do not forget to change the example code to:
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
// Don't show the shell.
// shell.open();
FileDialog dialog = new FileDialog (shell, SWT.OPEN | SWT.MULTI);
String[] filterNames = new String [] {"Todos los archivos (*)"};
String[] filterExtensions = new String [] {"*"};
String filterPath = "c:\";
dialog.setFilterNames (filterNames);
dialog.setFilterExtensions (filterExtensions);
dialog.setFilterPath (filterPath);
dialog.open();
System.out.println ("Selected files: ");
String[] selectedFileNames = dialog.getFileNames();
for(String fileName : selectedFileNames) {
System.out.println(" " + fileName);
}
shell.close();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
To modify the filters of accepted files you must modify the following lines, in this case we will allow only JPEG or PNG files:
String[] filterNames = new String [] {"JPEG (*.jpg)", "PNG (*.png)"};
String[] filterExtensions = new String [] {"*.jpg", "*.png"};
And this I have not tried but it should work also, it would offer 3 options, All the images, JPEG and PNG:
String[] filterNames = new String [] {"Todas las imagenes (*.jpg, *.png)", "JPEG (*.jpg)", "PNG (*.png)"};
String[] filterExtensions = new String [] {"*.jpg|*.png", "*.jpg", "*.png"};