How do I open the JavaFX FileChooser from a controller class?
For any node in your scene (for example, the root node; but any node you have injected with @FXML will do), do chooser.showOpenDialog(node.getScene().getWindow());
For any node in your scene (for example, the root node; but any node you have injected with @FXML will do), do chooser.showOpenDialog(node.getScene().getWindow());
You can simply create an image with Image image = new Image(selectedFile.toURI().toString()); and then place it in the ImageView: previewPicture.setImage(image); Other constructors offer more control over resources required for loading the image. If you want to force the image to be a certain size, you can resize it on loading, which will save memory if … Read more
It does not appear this is supported in Swing in Java 6. Currently, the simplest way I can find to open this dialog is through SWT, not Swing. SWT’s FileDialog (javadoc) brings up this dialog. The following is a modification of SWT’s FileDialog snippet to use an open instead of save dialog. I know this … Read more
How about using tkinter? from Tkinter import Tk # from tkinter import Tk for Python 3.x from tkinter.filedialog import askopenfilename Tk().withdraw() # we don’t want a full GUI, so keep the root window from appearing filename = askopenfilename() # show an “Open” dialog box and return the path to the selected file print(filename) Done!
EDIT (02 Jan 2012): I created a small open source Android Library Project that streamlines this process, while also providing a built-in file explorer (in case the user does not have one present). It’s extremely simple to use, requiring only a few lines of code. You can find it at GitHub: aFileChooser. ORIGINAL If you … Read more