Enhanced FileChooser

68 views
Skip to first unread message

Michael Ellis

unread,
Nov 20, 2023, 10:29:46 AM11/20/23
to ControlsFX
The JavaFX FileChooser is great and will emply platform specific, famiiar, UI. It, however lacks the ability to dislay a platform independent file preview.

On Windows I *think* you get a preview for common image file formats (*.jpg, *.png), but on linux even these are not rendered as a preview.

I Also have proprietary file formats that I can render as images and it would be nice to provide a means of displaying a preview in the FileChooser.

I'd love it the JavaFX FileChooser had  the ability to add a FilePreviewHandler:
   Node previewFile(Path);

Anyone have any thoughts on this?

If a whole platform independent FileChoose has to be implented then making it easily extensible for supporting previews of arbitrary fileformats would seem useful.

Mark Schmieder

unread,
Nov 21, 2023, 7:21:11 PM11/21/23
to ControlsFX
Could be useful. I ended up implementing my own preview pop-up window but only for importing graphics, so it has stuff like selecting drawing units for Cartesian space. I published this in my fxguitoolkit or maybe the addendum fxcadgui library on my GitHub page. But you might also just need something simple that doesn't require pre-parsing a file to load into a scene graph hosted by a large preview window, in which case you may be able to use JFreeOrg's JavaFX preview node. I have some examples of using this as well, in my GitHub libs.

I am just getting back into deep JavaFX programming after only sporadic use the past two years due to having to focus on refactoring an inherited computational engine that is quite complex. If I come across something a bit more specific to your post, in the next week, I'll try to remember to post here. We've only been doing headless apps for Linux though, and we don't support macOS, but as I have an iMac at home as my main developer box for remote work, I at least can test things on macOS and Windows, even if I can't do too much with Linux in an open source context vs. a classified environment.

Mark Schmieder

unread,
Apr 14, 2024, 2:10:28 PM4/14/24
to ControlsFX
Sorry for the delay, I wear far too many hats! My biggest concern about a custom file chooser that is NOT built atop the platform file chooser is that you lose out when the OS updates and new features are added top the platform, as well as diverging from the user's expectations. I got thrown last year when Windows 11 changed the file chooser experience, but I still think it is better to stick to the platform vs. a cross-platform experience such as in Swing.

What I wish we could do is add a node, as you say, such as what Adobe does with some of their apps. I wish I knew how they do it, as I don't think just anybody can gain access to what are probably private API's at the OS level so that they can add their hooks. maybe a licensing fee to Apple and Microsoft?

Technically, it is possible to do what you ask, and I did so for stuff that is published in my GitHub libraries, but the preview is AFTER the file is selected and it loads the appropriate parser or viewer for the file type (I wrote one for AutoCAD DWG files; image formats and vector graphics are of course built into JavaFX).

It is nice to see a thumbnail before selecting a file, of course, especially if it is a large one that may take a few minutes to parse and that may exhaust memory upon being converted to a viewable scene graph in JavaFX. Many file formats have raster image based thumbnails, of course, but these tend to interact with the native file system and in most cases I think this gives them the advantage of being displayable in the native file chooser. A home-grown solution might not.

Reply all
Reply to author
Forward
0 new messages