r/JavaFX • u/Fuzzy-System8568 • 1d ago
Help Any non-mvvmFX examples of MVVM for JavaFX?
Once again, in a bid to continue my efforts to learn the core of JavaFX (i.e. solutions without frameworks or libraries on top) I am wondering if anyone knows of some actual examples of MVVM being used in an JavaFX context, that isn't just relying on a third party library such as mvvmFX?
I want to see the concept without any of the magic of libraries / frameworks as, just like my other post about packaging, I feel something that is really missing in the JavaFX community is "from the ground up" guidance on core things, such as architecture.
So I either want to collate them into one place, or make my own resources to aid in filling this gap :)
4
u/sombriks 1d ago
I am not sure if it's what you're looking for, but try a search asking for reactive UI examples with JavaFx.
Mo need for extra frameworks besides javafx runtime itself.
I find this article, recommended to me a few days ago, a good read: https://www.pragmaticcoding.ca/javafx/techniques/reactive-javafx/
I am doing short experiments, but my snippets for this where exploring something else, but there: https://github.com/sombriks/project-layouts-jbang/blob/main/spread-deps/src/org/example/ui/Checkout.java
I hope it helps.
3
u/sedj601 1d ago
It's not MVVM, but I use MVC, as in https://stackoverflow.com/a/32343342/2423906. I use it with FXML, and it works great.
2
u/ThreeSixty404 JavaFX Dev 1d ago
It's not perfect but you can get a rough idea FeedFX
You should use at least a dependency injection framework though, to make things cleaner and more easily testable.
I personally always use Inverno, it's small but most importantly it's compile-time DI, so no black magic and no runtime performance cost
1
u/mstr_2 21h ago
JavaFX is not very well equipped for a textbook MVVM pattern. However, you can use FXML/2 (which is more like XAML) with JavaFX, which is tailored for the MVVM pattern: https://jfxcore.github.io/fxml-compiler/getting-started/mvvm.html
1
u/Siedlerchr 19h ago
You can take a look at JabRef, we only have afterburner.fx https://github.com/jabref/jabref for view instantiation but viewmodels etc and models are not using a framework.
-1
u/tankmatesaquaponics 1d ago
Read 'presentation model' by martin fawler. You can find the mvvm pattern elsewhere on the internet. Read it in any language, then implement it yourself in java.