I just added a standard \"Open file\" dialog to a small desktop app I\'m writing, based on the JFileChooser entry of the Swing Tutorial. It\'s generating a
John McCarthy's answer seems to be the best. Here some suggestions.
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.Image;
Add image on top left corner. It's important that you use "getResourceAsStream", you'll notice after export as Runnable jar:
Display display = new Display();
Shell shell = new Shell(display);
InputStream inputImage = getClass().getResourceAsStream("/app/launcher.png");
if (inputImage != null) {
shell.setImage(new Image(display, inputImage));
}
User's home directory:
String filterPath = System.getProperty("user.home");
Get absolut pathname instead of filter-dependent pathname, which is wrong on other drive.
String absolutePath = dialog.open();