JavaFX Dialogs, Anyone?
- by HecklerMark
A common question about JavaFX, especially for those coming from a Swing background, is "How do I do Dialogs?"
The reason this is a question at all is that, currently, there is no baked-in capability to do dialog boxes within a pure JavaFX 2.x application. But come on...you wouldn't be reading about this at all if you weren't a resourceful programmer. You have ways of making things happen. :-)
I ran across a decent patch of code recently that handles many of the dialog chores for you. Pros and cons follow, but pointing your browser to this link on Github (appropriately named JavaFXDialog) will get you off to a good start.
Here are some screen shots the original code author, Anton Smirnov, provided:
Nothing fancy, just clean and functional. Now, about those pros and cons. From my perspective, here's the bottom line:
Pros
Already developed. Time required to implement is limited to downloading and decompressing the file, doing a bit of reading, and writing a few lines of code to try things out.
Easy. Most of the work is done, and the interface is pretty simple.
Open source. If you want to make changes - and I'm already thinking along those lines, so you may as well admit you will, too - you can do it.
Cons
Documentation. What you see on the Wiki page is the extent of it.
Lack of activity. As of the date this article was published, the code hasn't been updated in several months...so the project is a bit stale.
To be fair, the cons listed above won't cause anyone to lose sleep. After all, you don't expect constant revisions against something that works well enough for most purposes, and if your needs exceed what is there, it's easy to mod the code yourself or "roll your own" if you prefer. The lack of documentation isn't a show-stopper either due to the limited functionality and complexity of the code.
Wrapping It Up
If you need a quick, drop-in dialog capability for your JavaFX 2.x app, give it a try and see what you think. And if you're already using something you like, please share it as well! I'd love to hear from you, take a look at what you pass along, and maybe do a "dialog shoot-out" article in the future. So..what works for you? :-)
All the best,
Mark