## Learning JavaFx2 - Part 1

#### Motivation

One of my projects has to written in Java or similar JVM language (not python sadly). It's a rich GUI application and I had to choose appropriate framework to develop user interface. After some research I found JavaFx.

I first wanted to do it in Groovy, dynamic language for JVM, but after I saw documentation of GroovyFx... I decided not to, because lots of subsection of this documentation was simply empty.

My project is not exceptionally ambitious and I wanted to do GUI as easily and fast and possible and then focus on major functionality of my app. I have developed some GUI's before in C++ and Python. And it was rather simple and intuitive process (I love Pyside!).

#### First impressions

I remember that I had some problems. I encountered very strange behavior of Intellij Ide, it was switching off after attempts to launch javafx project and I still don't know why. After some re-installations (SDK from Oracle and Netbeans IDE, which has default support for javafx) I started learning from the book: Pro JavaFX 2 which kindly provides source code.

I had custom installation of a development platform and I followed a tutorial, was it successful? Not. Some of the first examples from this book just doesn't compile on my computer. I lost lots of time, and found out that further examples works. WUT?

#### Philosophy

I think that's the main reason why JavaFX is so strange for me it's its javaland philosophy, which I'm not used to. I prefer thinking in terms of problem not in terms of framework. An approach where framework has so many solutions for me and is itself huge and has its own complicated philosophy is for me overwhelming.

Maybe I need more time for learning it and then using will be a piece of cake. I truly hope so.

#### Suprises

I read Pro JavaFx book to be able to build nice, simple and clean GUI. Documentation of Java libraries is usually not very friendly in my opinion, because it's usually automatically generated and there's too small signal to noise ratio whith all those classes and methods I usually doesn't need.

Funny thing is that one of the first application examples is a metronome, which uses a lots of transitions, which are quite funny in javafx. There a class and factory for everything. I usually think in terms on 2D canvas, but there it's implemented in different way. Nodes are binded to transitions and there is no trace of canvas.

Binding in JavaFx is a bit overwhelming. I've seen already at least 60 methods of public api connected with it. Nightmare! But it's quite useful when you get used to specific way of thinking about dynamic properties, which are observable, have event handlers and so on.

Chaining and builders are quite handy but they're not my favorite way of building objects, why not a wisely designed constructor? When construction of an object takes 50 lines of code, I simply get lost.

Here is an example of such code:

 java Some random node written in JavaFx



It's too long and it's ugly and my head's starting to ache.

#### Summary

I really start getting used to JavaFx peculiarities. Maybe I'll create beautiful GUI with it. I would really try but it may take some time. Stay tuned!

Opublikowano: | Źródło