Class DirectoryChooser
java.lang.Object
javafx.stage.DirectoryChooser
public final class DirectoryChooser extends Object
Provides support for standard directory chooser dialogs. These dialogs have look and feel of the platform UI components which is independent of JavaFX. On some platforms where file access may be restricted or not part of the user model (for example, on some mobile or embedded devices), opening a directory dialog may always result in a no-op (that is, null file being returned).
- Since:
- JavaFX 2.1
Property Summary
| Type | Property | Description |
|---|---|---|
final ObjectProperty |
initialDirectory |
The initial directory for the displayed dialog. |
final StringProperty |
title |
The title of the displayed dialog. |
Constructor Summary
| Constructor | Description |
|---|---|
DirectoryChooser() |
Creates a DirectoryChooser. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final File |
getInitialDirectory() |
Gets the value of the initialDirectory property. |
final String |
getTitle() |
Gets the value of the title property. |
final ObjectProperty |
initialDirectoryProperty() |
The initial directory for the displayed dialog. |
final void |
setInitialDirectory |
Sets the value of the initialDirectory property. |
final void |
setTitle |
Sets the value of the title property. |
File |
showDialog |
Shows a new directory selection dialog. |
final StringProperty |
titleProperty() |
The title of the displayed dialog. |
Property Details
title
public final StringProperty titleProperty
The title of the displayed dialog.
- See Also:
initialDirectory
public final ObjectProperty<File> initialDirectoryProperty
The initial directory for the displayed dialog.
- See Also:
Constructor Details
DirectoryChooser
public DirectoryChooser()
Creates a
DirectoryChooser.Method Details
setTitle
public final void setTitle(String value)
Sets the value of the
title property.- Property description:
- The title of the displayed dialog.
- Parameters:
-
value- the value for thetitleproperty - See Also:
getTitle
public final String getTitle()
Gets the value of the
title property.- Property description:
- The title of the displayed dialog.
- Returns:
- the value of the
titleproperty - See Also:
titleProperty
public final StringProperty titleProperty()
The title of the displayed dialog.
- Returns:
- the
titleproperty - See Also:
setInitialDirectory
public final void setInitialDirectory(File value)
Sets the value of the
initialDirectory property.- Property description:
- The initial directory for the displayed dialog.
- Parameters:
-
value- the value for theinitialDirectoryproperty - See Also:
getInitialDirectory
public final File getInitialDirectory()
Gets the value of the
initialDirectory property.- Property description:
- The initial directory for the displayed dialog.
- Returns:
- the value of the
initialDirectoryproperty - See Also:
initialDirectoryProperty
public final ObjectProperty<File> initialDirectoryProperty()
The initial directory for the displayed dialog.
- Returns:
- the
initialDirectoryproperty - See Also:
showDialog
public File showDialog(Window ownerWindow)
Shows a new directory selection dialog. The method doesn't return until the displayed dialog is dismissed. The return value specifies the directory chosen by the user or
null if no selection has been made. If the owner window for the directory selection dialog is set, input to all windows in the dialog's owner chain is blocked while the dialog is being shown.- Parameters:
-
ownerWindow- the owner window of the displayed dialog - Returns:
- the selected directory or
nullif no directory has been selected
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.