# FileChooserHandle

Import: `import com.install4j.api.test.ui.FileChooserHandle;`

```java
interface FileChooserHandle
```

A modal `JFileChooser` shown by a Browse button on a "Directory chooser" or
"File chooser" form component.

Reach this handle via [`Session.fileChooser`](../session/Session.md#filechooser).

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`selectFile(File)`](#selectfile-file) | `FileChooserHandle` | Select the given file in the chooser. |
| [`selectDirectory(File)`](#selectdirectory-file) | `FileChooserHandle` | Select the given directory in the chooser. |
| [`approve()`](#approve) | `void` | Click the chooser's Approve button, typically "Open" or "Save". |
| [`cancel()`](#cancel) | `void` | Click the chooser's Cancel button. |
| [`getCurrentDirectory()`](#getcurrentdirectory) | `File` | The directory the chooser is currently showing. |
| [`getSelectedFile()`](#getselectedfile) | `File` | The currently selected file, or `null` if none is selected. |

### selectFile(File)

```java
FileChooserHandle selectFile(File file)
```

Select the given file in the chooser.

### selectDirectory(File)

```java
FileChooserHandle selectDirectory(File directory)
```

Select the given directory in the chooser.

### approve()

```java
void approve()
```

Click the chooser's Approve button, typically "Open" or "Save".

### cancel()

```java
void cancel()
```

Click the chooser's Cancel button.

### getCurrentDirectory()

```java
File getCurrentDirectory()
```

The directory the chooser is currently showing.

### getSelectedFile()

```java
@Nullable File getSelectedFile()
```

The currently selected file, or `null` if none is selected.

