chrriis.dj.nativeswing.swtimpl.components
Class JFileDialog

java.lang.Object
  extended by chrriis.dj.nativeswing.swtimpl.components.JFileDialog

public class JFileDialog
extends Object

A native file selection dialog.

Author:
Christopher Deckers

Nested Class Summary
static class JFileDialog.DialogType
          The types that a file dialog supports.
static class JFileDialog.SelectionMode
          A representation of the selection modes that a file dialog supports.
 
Constructor Summary
JFileDialog()
           
 
Method Summary
 JFileDialog.DialogType getDialogType()
          Get the dialog type.
 String[] getExtensionFilters()
          Get the extension filters.
 String[] getExtensionFiltersNames()
          Get the names corresponding to the extension filters.
 String getParentDirectory()
          Get the parent directory of the files that will be/were shown.
 int getSelectedExtensionFilterIndex()
          Get the index of the selected extension filter.
 String getSelectedFileName()
          Get the file name of the first file that was selected relative to the parent directory.
 String[] getSelectedFileNames()
          Get the file names of the files that was selected relative to the parent directory.
 JFileDialog.SelectionMode getSelectionMode()
          Get the selection mode.
 String getTitle()
          Get the title of the file dialog.
 boolean isConfirmedOverwrite()
          Indicate whether save dialogs should ask for confirmation when the file that is selected already exists.
 void setConfirmedOverwrite(boolean isConfirmedOverwrite)
          For save dialogs, indicates whether the selection of a file should confirm the selection of an existing file.
 void setDialogType(JFileDialog.DialogType dialogType)
          Set the dialog type.
 void setExtensionFilters(String[] extensionFilters, String[] extensionFiltersNames, int selectedExtensionFilterIndex)
          Set the extension filters, with optional descriptions, and set which index is selected by default.
 void setParentDirectory(String parentDirectory)
          Set the parent directory of the files that will be shown.
 void setSelectedFileName(String selectedFileName)
          Set the file name that the dialog will select by default.
 void setSelectionMode(JFileDialog.SelectionMode selectionMode)
          Set the selection mode.
 void setTitle(String title)
          Set the title of the file dialog.
 void show(Component component)
          Show the file selection dialog, which is a blocking call until the user has made a choice.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JFileDialog

public JFileDialog()
Method Detail

show

public void show(Component component)
Show the file selection dialog, which is a blocking call until the user has made a choice.

Parameters:
component - The parent component.

getSelectedFileName

public String getSelectedFileName()
Get the file name of the first file that was selected relative to the parent directory.

Returns:
the file name or null if no file was selected.

getSelectedFileNames

public String[] getSelectedFileNames()
Get the file names of the files that was selected relative to the parent directory.

Returns:
the file names or null if no file was selected.

setSelectedFileName

public void setSelectedFileName(String selectedFileName)
Set the file name that the dialog will select by default.

Parameters:
selectedFileName - the name of the file to select or null if no file is to be selected.

getSelectionMode

public JFileDialog.SelectionMode getSelectionMode()
Get the selection mode.

Returns:
the selection mode.

setSelectionMode

public void setSelectionMode(JFileDialog.SelectionMode selectionMode)
Set the selection mode.

Parameters:
selectionMode - the selection mode to set.

getDialogType

public JFileDialog.DialogType getDialogType()
Get the dialog type.

Returns:
the dialog type.

setDialogType

public void setDialogType(JFileDialog.DialogType dialogType)
Set the dialog type.

Parameters:
dialogType - the type of dialog.

setConfirmedOverwrite

public void setConfirmedOverwrite(boolean isConfirmedOverwrite)
For save dialogs, indicates whether the selection of a file should confirm the selection of an existing file.

Parameters:
isConfirmedOverwrite - indicate whether selecting an existing file should confirm overwriting it.

isConfirmedOverwrite

public boolean isConfirmedOverwrite()
Indicate whether save dialogs should ask for confirmation when the file that is selected already exists.

Returns:
true when the dialog should ask for confirmation, false otherwise.

getParentDirectory

public String getParentDirectory()
Get the parent directory of the files that will be/were shown.

Returns:
The parent directory or null if it is not set.

setParentDirectory

public void setParentDirectory(String parentDirectory)
Set the parent directory of the files that will be shown.

Parameters:
parentDirectory - The parent directory or null to use the default.

setExtensionFilters

public void setExtensionFilters(String[] extensionFilters,
                                String[] extensionFiltersNames,
                                int selectedExtensionFilterIndex)
Set the extension filters, with optional descriptions, and set which index is selected by default. To clear the list, set both arrays to null.

Parameters:
extensionFilters - an array of extensions typically in the form "*.extension" or null. A filter with multiple extension uses semicolon as a separator, e.g. "*.jpg;*.png".
extensionFiltersNames - the array of names corresponding to each extension filter, or null.
selectedExtensionFilterIndex - the index that is selected by default.

getExtensionFilters

public String[] getExtensionFilters()
Get the extension filters.

Returns:
the extension filters, or null if not set.

getExtensionFiltersNames

public String[] getExtensionFiltersNames()
Get the names corresponding to the extension filters.

Returns:
the extension filters names, or null if not set.

getSelectedExtensionFilterIndex

public int getSelectedExtensionFilterIndex()
Get the index of the selected extension filter.

Returns:
the selected extension filter index.

setTitle

public void setTitle(String title)
Set the title of the file dialog.

Parameters:
title - the title to set or null to use the default title.

getTitle

public String getTitle()
Get the title of the file dialog.

Returns:
the title or null if it is not set.