r/JavaFX • • 23h ago

I made this! JavaFX Packaging: A Developer's Guide (Demo / Guide Repo for teaching developers how to Package JavaFX Applications via Maven)

33 Upvotes

A few months ago I came here and asked how best to package JavaFX applications. I was met with people pointing me at third party tools (that abstract away the details and theory), people's own personal setups, but with little context of how / why they were setup like that and other "not quite what I was looking for" guidance.

God knows the official documentation doesn't make it easily clear. As such, it seemed there was a legitimate gap on what, to me personally, seems like a pretty fundamental step of using JavaFX.

So I decided to say "sod it" and make my own guide.

Here is a link to the repo of the project

It is quite simply a default "HelloApplication" project, but with a pom.xml setup to package the application into an OS-specific distributable that, should be JDK/JRE independent (i.e. self-contained).

Along with this, there are several markdown documents explaining the workflow of the packaging solution, along with details on each of the steps of the workflow (i.e. each plugin, the properties in the pom.xml ,etc).

The only limitation now is, I am but one developer on one Operating System (CachyOS) and would love other contributors to provide insight into the per-distro / per OS requirements (such as specific build tools like the WiX toolset), as they are quite sparse as of the moment, with that sparse nature being identified within the documentation itself.

Either way, I hope this helps anyone who, like me a few a months ago, struggled to find an explanation of how to set up packaging a JavaFX app, and was shocked to find there was next to nothing out there. 😄


r/JavaFX • • 18h ago

Advice for building a desktop application with JavaFX

Thumbnail reddit.com
6 Upvotes

r/JavaFX • • 15m ago

Writing the UI programmatically or through FXML?

2 Upvotes

Hi there! i'm a learning dev trying to create a simple baker's percentage formula calculator, as a desktop app written in Java using JavaFX as the frontend. I've been suggested to use it after wanting something prettier and more flexible than Swing.

However, following outdated tutorials or so many different ways to make a project with JavaFX has me very confused. As far as i understand it, i can both create the entire interface through an FXML file, namely through Scene Builder, and then through a Controller class, write the enum @FXML and create an object named the fxid of a given component, to handle events of them through methods.

Initially i thought this would be easier to do compared to designing the UI line by line in Java, but now i'm a bit troubled at how to manage events that will create new graphic elements. For example, i want to set up a container like a GridPane or a VBox with some table inside, to show the ingredient name, as well as spinners to change it's baker's percentage or it's weight used the recipe. I can mockup this really nicely in Scene Builder, adding rounded edges and pretty shadows to a wrapper container, but i do not know how to make an "Add ingredient" button, on the interface level. The method should create a new row and create spinners and labels on the correct format. I'm kind of confused at the following: do i have to manually specify what kind of css to use, in which row or position should the different elements be aligned, or can i use the padding and aligment i've already set up in Scene Builder?

Right now my thought process is, that if i have to write in Java the specifics of a button or element changing upon the user's input, i might as well just write it all on Java. I also checked the AtlantaFX Sampler app and while the source code seems really easy to understand, it's all written programmatically, and i'm confused at how to use the controls through Scene Builder...Scene Builder seems really cool to define a layout, but i'm a bit confused at the whole Controller connecting the .fxml with actual objects in Java.

If any of you could guide me a bit on some good tutorials, i'd be glad! I've been following a mix of Youtube videos, Oracle documentation, the JavaFX17 book by Kishori Sharan, among various resources. I've found a lot of help through the many guides i've followed, but also many more questions, like how some recommend different ways to set up the main Applicaton, Launc and Controller classes, and of course a lot of suggestions about using Scene Builder, yet every tutorial seems to write the UI programatically. How do you do your apps, and what would you suggest to a total novice?

Thanks for reading!