Skip to content

Repository files navigation

Maven Central

Native File Dialog Java

A Kotlin/Java wrapper around the small C library by Bernard Teo (btzy/nativefiledialog-extended). As a fallback it uses default AWT file picker.

A library is a perfect fit for the Jetpack Compose for Desktop.

Supported platforms:

  • Windows;
  • MacOS;
  • Linux (GTK).

Download

repositories {
mavenCentral()
}
dependencies {
implementation("tv.wunderbox:nativefiledialog:$nativeFileDialogVersion")
}

API

interfaceFileDialog {
funsave(
filters:List<Filter> = emptyList(),
defaultPath:String? = null,
defaultName:String? = null,
): FileDialogResult<File>
funpickFile(
filters:List<Filter> = emptyList(),
defaultPath:String? = null,
): FileDialogResult<File>
funpickFileMany(
filters:List<Filter> = emptyList(),
defaultPath:String? = null,
): FileDialogResult<List<File>>
funpickDirectory(
defaultPath:String? = null,
): FileDialogResult<File>
}

Example usage

val fileDialog =FileDialog.default(awtComponent)
val result = fileDialog.pickFile() // returns FileDialogResult<File>when (result) {
isFileDialogResult.Success-> {
val file = result.value
// Handle success
}
isFileDialogResult.Failure-> {
// Handle failure
}
}
Create picker directly

Internally there are two different implementations available, instead of using the default NfdFileDialog with AwtFileDialog as a fallback, you can use only one:

val nfdFileDialog =NfdFileDialog()
val awtFileDialog =AwtFileDialog(awtComponent)

When using Kotlin Compose Multiplatform the awtComponent variable is a ComposeWindow object that might be obtained from androidx.compose.ui.window.WindowScope.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages