jruby/docs BETA
org.eclipse.swt.widgets 61
C Button
C Canvas
C Caret
C ColorDialog
C Combo
C Composite
C Control
C CoolBar
C CoolItem
C DateTime
C Decorations
C Dialog
C DirectoryDialog
C Display
C Event
C ExpandBar
C ExpandItem
C FileDialog
C FontDialog
C Group
C IME
C Item
C Label
C Layout
C Link
C List
I Listener
C Menu
C MenuItem
C MessageBox
C Monitor
C ProgressBar
C Sash
C Scale
C ScrollBar
C Scrollable
C Shell
C Slider
C Spinner
C Synchronizer
C TabFolder
C TabItem
C Table
C TableColumn
C TableItem
C TaskBar
C TaskItem
C Text
C ToolBar
C ToolItem
C ToolTip
C Touch
C TouchSource
C Tracker
C Tray
C TrayItem
C Tree
C TreeColumn
C TreeItem
C TypedListener
C Widget
FileDialog — members 17+
C new(parent)
C new(parent, style)
M file_name() String
C file_name=(string)
M file_names() String[]
M filter_extensions() String[]
C filter_extensions=(extensions)
M filter_index() int
C filter_index=(index)
M filter_names() String[]
C filter_names=(names)
M filter_path() String
C filter_path=(string)
M open() String
M open_dialog() Optional<String>
M overwrite() boolean
C overwrite=(overwrite)
from Dialog
M parent() Shell
M style() int
M text() String
C text=(string)

org.eclipse.swt.widgets.FileDialog

class extends Dialog 17 members

Instances of this class allow the user to navigate the file system and select or enter a file name.

Styles:
SAVE, OPEN, MULTI
Events:
(none)

Note: Only one of the styles SAVE and OPEN may be specified.

IMPORTANT: This class is not intended to be subclassed.

Constructors

new

new ( Shell parent )
Java: <init>(org.eclipse.swt.widgets.Shell parent)

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

nametypedescription
parentorg.eclipse.swt.widgets.Shella shell which will be the parent of the new instance

Throws

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

new

new ( Shell parent, int style )
Java: <init>(org.eclipse.swt.widgets.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.

nametypedescription
parentorg.eclipse.swt.widgets.Shella shell which will be the parent of the new instance
styleintthe style of dialog to construct

Throws

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

Instance Methods

file_name

String file_name ( )
Java: getFileName() · also: get_file_name

Returns the path of the first file that was selected in the dialog relative to the filter path, or an empty string if no such file has been selected.

Returns: the relative path of the file

file_name=

file_name= ( String string )
Java: setFileName(String string) · also: set_file_name

Set the initial filename which the dialog will select by default when opened to the argument, which may be null. The name will be prefixed with the filter path when one is supplied.

nametypedescription
stringStringthe file name

file_names

String[] file_names ( )
Java: getFileNames() · also: get_file_names

Returns a (possibly empty) array with the paths of all files that were selected in the dialog relative to the filter path.

Returns: the relative paths of the files

filter_extensions

String[] filter_extensions ( )
Java: getFilterExtensions() · also: get_filter_extensions

Returns the file extensions which the dialog will use to filter the files it shows.

Returns: the file extensions filter

filter_extensions=

filter_extensions= ( String[] extensions )
Java: setFilterExtensions(String[] extensions) · also: set_filter_extensions

Set the file extensions which the dialog will use to filter the files it shows to the argument, which may be null.

The strings are platform specific. For example, on some platforms, an extension filter string is typically of the form "*.extension", where "*.*" matches all files. For filters with multiple extensions, use semicolon as a separator, e.g. "*.jpg;*.png".

Note: On Mac, setting the file extension filter affects how app bundles are treated by the dialog. When a filter extension having the app extension (.app) is selected, bundles are treated as files. For all other extension filters, bundles are treated as directories. When no filter extension is set, bundles are treated as files.

nametypedescription
extensionsString[]the file extension filter

filter_index

int filter_index ( )
Java: getFilterIndex() · also: get_filter_index

Get the 0-based index of the file extension filter which was selected by the user, or -1 if no filter was selected.

This is an index into the FilterExtensions array and the FilterNames array.

Returns: index the file extension filter index

filter_index=

filter_index= ( int index )
Java: setFilterIndex(int index) · also: set_filter_index

Set the 0-based index of the file extension filter which the dialog will use initially to filter the files it shows to the argument.

This is an index into the FilterExtensions array and the FilterNames array.

nametypedescription
indexintthe file extension filter index

filter_names

String[] filter_names ( )
Java: getFilterNames() · also: get_filter_names

Returns the names that describe the filter extensions which the dialog will use to filter the files it shows.

Returns: the list of filter names

filter_names=

filter_names= ( String[] names )
Java: setFilterNames(String[] names) · also: set_filter_names

Sets the names that describe the filter extensions which the dialog will use to filter the files it shows to the argument, which may be null.

Each name is a user-friendly short description shown for its corresponding filter. The names array must be the same length as the extensions array.

nametypedescription
namesString[]the list of filter names, or null for no filter names

filter_path

String filter_path ( )
Java: getFilterPath() · also: get_filter_path

Returns the directory path that the dialog will use, or an empty string if this is not set. File names in this path will appear in the dialog, filtered according to the filter extensions.

Returns: the directory path string

filter_path=

filter_path= ( String string )
Java: setFilterPath(String string) · also: set_filter_path

Sets the directory path that the dialog will use to the argument, which may be null. File names in this path will appear in the dialog, filtered according to the filter extensions. 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.

nametypedescription
stringStringthe directory path

open

String open ( )
Java: open()

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

Returns: a string describing the absolute path of the first selected file, or null if the dialog was cancelled or an error occurred

Throws

SWTException
  • ERROR_WIDGET_DISPOSED - if the dialog has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog

open_dialog

Optional<String> open_dialog ( )
Java: openDialog()

Makes the dialog visible and brings it to the front of the display. Equal to FileDialog#open() but also exposes for state information like user cancellation.

Returns: an Optional that either contains the absolute path of the first selected file or is empty in case the dialog was canceled

Throws

SWTException
  • ERROR_WIDGET_DISPOSED - if the dialog has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog
  • ERROR_INVALID_RETURN_VALUE - if the dialog was not cancelled and did not return a valid path

overwrite

boolean overwrite ( )
Java: getOverwrite() · also: get_overwrite

Returns the flag that the dialog will use to determine whether to prompt the user for file overwrite if the selected file already exists.

Returns: true if the dialog will prompt for file overwrite, false otherwise

overwrite=

overwrite= ( boolean overwrite )
Java: setOverwrite(boolean overwrite) · also: set_overwrite

Sets the flag that the dialog will use to determine whether to prompt the user for file overwrite if the selected file already exists.

Note: On some platforms where suppressing the overwrite prompt is not supported, the prompt is shown even when invoked with overwrite false.

nametypedescription
overwritebooleantrue if the dialog will prompt for file overwrite, false otherwise

Inherited

from Dialog

parent

Shell parent ( )
Java: getParent() · also: get_parent

Returns the receiver's parent, which must be a Shell or null.

Returns: the receiver's parent

Throws

SWTException
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

style

int style ( )
Java: getStyle() · also: get_style

Returns the receiver's style information.

Note that, the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created.

Returns: the style bits

Throws

SWTException
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

text

String text ( )
Java: getText() · also: get_text

Returns the receiver's text, which is the string that the window manager will typically display as the receiver's title. If the text has not previously been set, returns an empty string.

Returns: the text

Throws

SWTException
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

text=

text= ( String string )
Java: setText(String string) · also: set_text

Sets the receiver's text, which is the string that the window manager will typically display as the receiver's title, to the argument, which must not be null.

nametypedescription
stringStringthe new text

Throws

IllegalArgumentException
  • ERROR_NULL_ARGUMENT - if the text is null
SWTException
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver