The new DirectoryChooser instance creates the dialog for selection. The method #showDialog() opens the dialog and returns the state of the DirectoryChooser. If an error occurs while determining canonical path a new dialog comes up with detailed error information.

All relevant lines are highlighted. Press the "Run..." button to start the example.