I want to set FileChooser
dialog preferred size. For now, it cannot be set and just appears with fixed size always (occupied with almost full screen). I can't find resizing method in FileChooser
intance and even control dialog after it appears.

- 203,806
- 29
- 246
- 1,045

- 3
- 2
2 Answers
I don't think that this is possible. The documentation of FileChooser states
Provides support for standard platform file dialogs. (...) The configuration of the displayed dialog is controlled by the values of the FileChooser properties set before the corresponding show*Dialog method is called. This configuration includes the dialog's title, the initial directory displayed in the dialog and the extension filter(s) for the listed files.
The popup dialog is provided by your operating system, so it cannot be customized directly. Your only option is using the bit of API that the FileChooser class itself provides. Since JavaFX is a cross platform UI framework, the customization options probably have been limited to the ones that are supported natively by all major platforms.
If you absolutely must customize the file chooser, you can try to embed a Swing JFileChooser in your JavaFX app.

- 195
- 9
-
Thank you for your good answere. It is so helpful that I understand this. I don't know why I can't control size of the dialog after invoking dialog. Maybe something is blocking that. – fxconcepts Jul 25 '22 at 03:42
-
Are you referring to the FileChooser or JFileChooser dialog? In case of the JavaFX FileChooser, there just aren't any methods in it that you can use to change its size. The size will be automatically set by your platform. If you were referring to the JFileChooser and cannot get it to work maybe open another question. – Duff Jul 25 '22 at 06:58
As noted here, the JavaFX FileChooser
is provided by the host platform. In particular, "For configuration properties which values haven't been set explicitly, the displayed dialog uses their platform default values." Presumably, this includes size.
- On macOS, Java/FX 17 LTS, if you resize the dialog, the new dialog size is saved as a preference; when invoked again, the last used dialog size is restored.
Please feel free to add your user experience on other platforms. This FileChooserDemo
can be used for testing.

- 203,806
- 29
- 246
- 1,045
-
thank you for your great answere. In my case I'm using window and I can't control the size at all after invoking. – fxconcepts Jul 25 '22 at 03:37