Is there a Java alternative to these technologies? I find the data binding capabilities and INotifyPropertyChanged of most use (along with containers and elements of the sort), but the lack of cross-platform of .NET makes me think of Java. What do you suggest? Is there any equivalent product? One that implements XAML?
The technology (WPF)
If you are looking for an alternative to WPF for the Java platform you should take a look at JavaFX.
The technology is very similar to WPF in the following ways:
Node
objects (which is similar to the WPF visual tree which consists of UIElement
objects).Pane
node and it's derivatives are conceptually similar to the WPF layout panels.Take a look at my answer to the question how does JavaFx compare to WPF which provides a much more detailed (but still high level) comparison of WPF and JavaFX.
The design pattern (MVVM)
The MVVM pattern is a specialisation of the presentation model pattern. It is possible to create a variation of this in JavaFX as the platform provides properties that support binding and the presentation model is basically an object that encapsulates the state of the model and provides operations that act upon that state.
Most examples I have seen though use a variant of the model-view-presenter pattern. Out of the box JavaFX supports a very simple MVP structure where each view is associated with a 'controller' class. This is fine for small applications but doesn't really provide great separation of concerns.
Maybe you should keep an eye on the fantastic MVVMFX Framework. Based on the parallels between WPF and JavaFX like descriptive UI declaration (FXML/XAML) they tried to adopt best practices of the development with WPF.
It supports, of course, Databinding concepts and implements the necessary interfaces for notifications between the view, viewModel and the model. UI and its UI-Logic (code behind) is realized with fxml-files (created with Scene Builder) and the obligatory Java class. With many good examples it isn't that hard to understand their concepts because it is a strict implementation of the purest MVVM-Pattern. All you need is to establish the framework in your project dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With