javafx-wrapper

JavaFX FileChooser and DirectoryChooser adapter that can be used in a Swing application.

License

License

Categories

Categories

JavaFX User Interface
GroupId

GroupId

com.github.mrcjkb
ArtifactId

ArtifactId

javafx-wrapper
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

javafx-wrapper
JavaFX FileChooser and DirectoryChooser adapter that can be used in a Swing application.
Project URL

Project URL

https://github.com/MrcJkb/jfx-filechooser-adapter/
Source Code Management

Source Code Management

https://github.com/MrcJkb/jfx-filechooser-adapter/

Download javafx-wrapper

Dependencies

runtime (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.10
org.openjfx : javafx-swing jar 11
org.openjfx : javafx-base jar 11
org.openjfx : javafx-graphics jar 11

Project Modules

There are no modules declared in this project.

jfx-filechooser-adapter

An adapter for a JavaFX File- and DirectoryChooser that allows for use in Swing

Maven Central

Requirements

  • Java 11
  • JavaFX 11.0.2 Jmods

Usage

The class JfxFileChooserAdapterModuleContext provides the module context, from which the file chooser builder can be accessed:

JfxFileChooserAdapterModuleContext.getFileChooserBuilder()

To begin invocation, call the init() or the init(String identifier) method. The optional identifier parameter can be used to remember the last selected directory. Without a parameter, a default identifier is used. From there, the fluent API has been designed to guide you through the valid options. Depending on previous choices, invalid options are hidden from the interface.

See the demo project for usage examples.

Setting a Swing parent window for the JavaFX FileChooser or DirectoryChooser

To set a Swing parent window, the IFileChooserBuilder interface provides the optional method addToSwingParent(Consumer<JComponent> addToSwingParentCallback). If this method is called, and the addToSwingParentCallback adds the provided (invisible) JComponent to a Swing Container, the Container's parent window is detected. Upon invocation, the file chooser builder attempts to position the file chooser on top of the detected Swing window. Unfortunately, this does not always work (e.g. on Windows 10, in a multi monitor setup).

Contribution

Architecture

This project is split into a parent project with three subprojects:

  • jfx-filechooser-adapter-parent: Contains the module context, which provides the entry to the API
  • jfx-filechooser-adapter-api: Contains the Java interfaces
  • jfx-filechooser-adapter-impl: Contains the implementation
  • javafx-wrapper: A wrapper for encapsulating JavaFX from the main projects

Additionally, the project jfx-filechooser-adapter-demo is included for demonstration purposes.

It is intended that a client accesses only the jfx-filechooser-adapter-parent project directly, which encapsulates the implementations. Architecture rules are enforced using ArchUnit.

Limitations

Due to a bug in Gradle JavaFX plugin, no tests can be added to the javafx-wrapper project.

Versions

Version
1.0.1
1.0.0
0.0.1