Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class DirectoryDialog

extends Dialog
Class Inheritance
Imports
java.io.*, org.eclipse.swt.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class allow the user to navigate the file system and select a directory.
Styles:
(none)
Events:
(none)

Important Note

This class is not intended to be subclassed.

See Also
DirectoryDialog snippets, SWT Example: ControlExample, Dialog tab, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv String
pack-priv static final String
Inherited from org.eclipse.swt.widgets.Dialog:
parentstyletitle

Constructor Summary

AccessConstructor and Description
public
DirectoryDialog(Shell
a shell which will be the parent of the new instance
parent
)

Constructs a new instance of this class given only its parent.

public
DirectoryDialog(Shell
a shell which will be the parent of the new instance
parent
,
int
the style of dialog to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the filter path
getFilterPath
()

Returns the path which the dialog will use to filter the directories it shows.

public String

Returns:

the message
getMessage
()

Returns the dialog's message, which is a description of the purpose for which it was opened.

pack-priv void
GTK3setNativeDialogMessage(long handle, String message)

GTK3 only function.

public String

Returns:

a string describing the absolute path of the selected directory, or null if the dialog was cancelled or an error occurred
open
()

Makes the dialog visible and brings it to the front of the display.

pack-priv String

Returns:

a string describing the absolute path of the first selected file, or null
openNativeChooserDialog
()

Open the file chooser dialog using the GtkFileChooserNative API (GTK3.20+) for running applications without direct filesystem access (such as Flatpak).

public void
setFilterPath(String
the filter path
string
)

Sets the path that the dialog will use to filter the directories it shows to the argument, which may be null.

public void
setMessage(String
the message
string
)

Sets the dialog's message, which is a description of the purpose for which it was opened.

Inherited from org.eclipse.swt.widgets.Dialog:
checkParentcheckStylecheckSubclasserrorgetParentgetStylegetTextsetText

Field Detail

filterPathback to summary
pack-priv String filterPath
messageback to summary
pack-priv String message
SEPARATORback to summary
pack-priv static final String SEPARATOR

Constructor Detail

DirectoryDialogback to summary
public DirectoryDialog(Shell parent)

Constructs a new instance of this class given only its parent.

Parameters
parent:Shell

a shell which will be the parent of the new instance

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
DirectoryDialogback to summary
public DirectoryDialog(Shell parent, int style)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters
parent:Shell

a shell which will be the parent of the new instance

style:int

the style of dialog to construct

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass

Method Detail

getFilterPathback to summary
public String getFilterPath()

Returns the path which the dialog will use to filter the directories it shows.

Returns:String

the filter path

See Also
setFilterPath
getMessageback to summary
public String getMessage()

Returns the dialog's message, which is a description of the purpose for which it was opened. This message will be visible on the dialog while it is open.

Returns:String

the message

GTK3setNativeDialogMessageback to summary
pack-priv void GTK3setNativeDialogMessage(long handle, String message)

GTK3 only function. As of GTK4, gtk_file_chooser_set_extra_widget is no longer available, and the alternatives do not allow for such flexibility to display just the message. Therefore in GTK4, there will be no message displayed in the file chooser dialog.

openback to summary
public String open()

Makes the dialog visible and brings it to the front of the display.

Returns:String

a string describing the absolute path of the selected directory, or null if the dialog was cancelled or an error occurred

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the dialog has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog
openNativeChooserDialogback to summary
pack-priv String openNativeChooserDialog()

Open the file chooser dialog using the GtkFileChooserNative API (GTK3.20+) for running applications without direct filesystem access (such as Flatpak). API for GtkFileChoosernative does not give access to any GtkWindow or GtkWidget for the dialog, thus this method omits calls that requires such access. These are be handled by the GtkNativeDialog API.

Returns:String

a string describing the absolute path of the first selected file, or null

setFilterPathback to summary
public void setFilterPath(String string)

Sets the path that the dialog will use to filter the directories it shows to the argument, which may be null. If the string is null, then the operating system's default filter path will be used.

Note that the path string is platform dependent. For convenience, either '/' or '\' can be used as a path separator.

Parameters
string:String

the filter path

setMessageback to summary
public void setMessage(String string)

Sets the dialog's message, which is a description of the purpose for which it was opened. This message will be visible on the dialog while it is open.

Note

This operation is a hint and is not supported on some platforms. For example, on Windows (Vista and later), the DirectoryDialog doesn't have any provision to set a message.

Parameters
string:String

the message

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the string is null