APIdia Launch Partner
Top Inners Constructors Methods
com.sun.glass.ui

public Class CommonDialogs

extends Object
Class Inheritance
Imports
java.lang.annotation.Native, java.io.IOException, .File, java.util.List, .ArrayList

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CommonDialogs.ExtensionFilter

Provides a mechanism to filter different kinds of file name extensions.

public static class
CommonDialogs.FileChooserResult

An object representing the result of showing a file chooser dialog.

public static class
CommonDialogs.Type

Available file chooser types.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
private static String
protected static CommonDialogs.FileChooserResult
createFileChooserResult(String[] files, CommonDialogs.ExtensionFilter[] extensionFilters, int index)

public static CommonDialogs.FileChooserResult

Returns:

the files that the user selects and the selected extension filter. If the user cancels the file chooser, the method returns empty results object.
showFileChooser
(Window
the owner window for this file chooser (may be null)
owner
,
File
the initial folder, may be null
folder
,
String
the initial file name for a SAVE dialog (may be null)
filename
,
String
the title of the file chooser
title
,
int
the type of the file chooser, one of the constants from Type
type
,
boolean
enables or disable multiple file selections
multipleMode
,
List<CommonDialogs.ExtensionFilter>
the filters of the file chooser
extensionFilters
,
int
the zero-based index of the filter selected by default
defaultFilterIndex
)

Creates a native file chooser that lets the user select files.

public static File

Returns:

the folder that the user selects. If the user cancels the folder chooser, the method returns null.
showFolderChooser
(Window
the owner window for this folder chooser (may be null)
owner
,
File
the initial folder, may be null
folder
,
String
the title of the folder chooser
title
)

Creates a native folder chooser that lets the user selects folder.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CommonDialogsback to summary
private CommonDialogs()

Method Detail

convertFolderback to summary
private static String convertFolder(File folder)
convertTitleback to summary
private static String convertTitle(String title)
createFileChooserResultback to summary
protected static CommonDialogs.FileChooserResult createFileChooserResult(String[] files, CommonDialogs.ExtensionFilter[] extensionFilters, int index)
showFileChooserback to summary
public static CommonDialogs.FileChooserResult showFileChooser(Window owner, File folder, String filename, String title, int type, boolean multipleMode, List<CommonDialogs.ExtensionFilter> extensionFilters, int defaultFilterIndex)

Creates a native file chooser that lets the user select files.

Parameters
owner:Window

the owner window for this file chooser (may be null)

folder:File

the initial folder, may be null

filename:String

the initial file name for a SAVE dialog (may be null)

title:String

the title of the file chooser

type:int

the type of the file chooser, one of the constants from Type

multipleMode:boolean

enables or disable multiple file selections

extensionFilters:List<CommonDialogs.ExtensionFilter>

the filters of the file chooser

defaultFilterIndex:int

the zero-based index of the filter selected by default

Returns:CommonDialogs.FileChooserResult

the files that the user selects and the selected extension filter. If the user cancels the file chooser, the method returns empty results object.

Exceptions
IllegalArgumentException:
if the initial folder is an invalid folder; if the type doesn't equal one of the constants from Type
showFolderChooserback to summary
public static File showFolderChooser(Window owner, File folder, String title)

Creates a native folder chooser that lets the user selects folder.

Parameters
owner:Window

the owner window for this folder chooser (may be null)

folder:File

the initial folder, may be null

title:String

the title of the folder chooser

Returns:File

the folder that the user selects. If the user cancels the folder chooser, the method returns null.

com.sun.glass.ui back to summary

public final Class CommonDialogs.ExtensionFilter

extends Object
Class Inheritance

Provides a mechanism to filter different kinds of file name extensions. The following example creates an ExtensionFilter that will show txt files:
    List extensions = new ArrayList();
    extensions.add("*.txt");
    ExtensionFilter filter = new ExtensionFilter("Text files", extensions);
    List filters = new ArrayList();
    filters.add(filters);
    FileChooser.show(..., filters);
See Also
showFileChooser

Field Summary

Modifier and TypeField and Description
private final String
private final List<String>

Constructor Summary

AccessConstructor and Description
public
ExtensionFilter(String
the textual description for the filter
description
,
List<String>
the accepted file name extensions
extensions
)

Creates an ExtensionFilter with the specified description and the file name extensions.

Method Summary

Modifier and TypeMethod and Description
private String[]
public String
public List<String>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

descriptionback to summary
private final String description
extensionsback to summary
private final List<String> extensions

Constructor Detail

ExtensionFilterback to summary
public ExtensionFilter(String description, List<String> extensions)

Creates an ExtensionFilter with the specified description and the file name extensions.

Parameters
description:String

the textual description for the filter

extensions:List<String>

the accepted file name extensions

Exceptions
IllegalArgumentException:
if the description of the filter is null or empty; if the extensions is null, empty or contains an empty string

Method Detail

extensionsToArrayback to summary
private String[] extensionsToArray()
getDescriptionback to summary
public String getDescription()
getExtensionsback to summary
public List<String> getExtensions()
com.sun.glass.ui back to summary

public final Class CommonDialogs.FileChooserResult

extends Object
Class Inheritance

An object representing the result of showing a file chooser dialog.

Field Summary

Modifier and TypeField and Description
private final List<File>
private final CommonDialogs.ExtensionFilter

Constructor Summary

AccessConstructor and Description
public
FileChooserResult(List<File>
should not be null, may be an empty list
files
,
CommonDialogs.ExtensionFilter filter)

Creates a new result object.

public
FileChooserResult()

Creates an empty results object.

Method Summary

Modifier and TypeMethod and Description
public CommonDialogs.ExtensionFilter
getExtensionFilter()

Returns the ExtensionFilter selected by a user when a file chooser dialog is closed.

public List<File>
getFiles()

Returns a list of selected files.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

filesback to summary
private final List<File> files
filterback to summary
private final CommonDialogs.ExtensionFilter filter

Constructor Detail

FileChooserResultback to summary
public FileChooserResult(List<File> files, CommonDialogs.ExtensionFilter filter)

Creates a new result object.

Parameters
files:List<File>

should not be null, may be an empty list

FileChooserResultback to summary
public FileChooserResult()

Creates an empty results object. Used when a user cancels a file chooser dialog.

Method Detail

getExtensionFilterback to summary
public CommonDialogs.ExtensionFilter getExtensionFilter()

Returns the ExtensionFilter selected by a user when a file chooser dialog is closed. A reference to one of the extension filter objects passed to the showFileChooser() method. May be null.

getFilesback to summary
public List<File> getFiles()

Returns a list of selected files. If a user cancels the dialog then this list is empty. Note that in case of a SAVE dialog the file name extension corresponding to the selected ExtensionFilter may not be appended automatically. Client code is responsible for checking the file name and appending the extension if needed. Use getExtensionFilter to obtain the selected File Type filter.

com.sun.glass.ui back to summary

public final Class CommonDialogs.Type

extends Object
Class Inheritance

Available file chooser types.
See Also
showFileChooser

Field Summary

Modifier and TypeField and Description
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
Type()

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

OPENback to summary
public static final int OPEN
Annotations
@Native
SAVEback to summary
public static final int SAVE
Annotations
@Native

Constructor Detail

Typeback to summary
public Type()