Last I have the opportunity to acquaint themselves with technology, JavaFX and I'd like to share with you my thoughts on it.
Static typing
JavaFX language is statically (strongly) typed, with a developed mechanism of Type Inference, that is - from English to ours - "guessing" types ". It is very cool that we save a little typing in the variable declaration as a record (valid)
var string: String = "Hello World!"equally valid, we can replace a record
var string = "Hello World!"and since then the compiler already knows (guess) that the string is String.
Binding level language
Noteworthy binding mechanism introduced at the level of language . It is very interesting and useful in many places. For example, write:
currentTextBoxValue var = "";means that whenever you type something in the text box (TextBox), the content of this field will be automatically rewritten to the variable currentTextBoxValue , and whenever you change the value of currentTextBoxValue , updated the contents of the text box. This mechanism saves time writing many listenerów, although it seems to me that badly used, can also be a source of consternation when the variables will "magically" change its value;)
....
TextBox {value: bind with inverse currentTextBoxValue
}
Closures (closures)
subject known Java lovers, or even the discussion introduce the mechanism for the next version or not:) The JavaFX available:
var x = 1;
SwingButton
{action: function (): Void {
x + +;}
text: "Increment"
}
Conceptually, this involves the transfer functions (closure, called closure) as the parameter "somewhere else", but this function when the recipient decides to do it, its performance will take place in a context in which the function was created. Also very convenient solution to quickly obtain a desirable effect.
Access Modifiers
JavaFX developers probably decided to discourage developers from using how can we close getter and setter , providing a number of new field access modifiers such as:
public-init - allows the modification of the field only during object creation
public-read - allows read-only access from the outside
no constructors, init blocks and postinit
So yes - there is no space for JavaFX constructors. Create objects using a special form of expression:
var circle = Circle {fill
: null
stroke: Color.BLACK
strokeWidth: 3
centerx: 22,
centery: 33,
radius: 44}
Within parentheses braces set of class fields, but here there is no complete freedom, because We limit the access modifiers of these fields.
To ensure the integrity of the object inside the class we create a block postinit , which will be made shortly after the creation of the object and set its value in fields:
postinit {if (model == null) {throw new IllegalStateException
("Model can not be null! ");}
}
Integration with Java
very important information - from within JavaFX can be used in classes Javowych (this can be seen even in the example above, when I throw a good old IllegalStateException). Restriction relates to the binding - you can not bind to the fields of classes written in Java.
stock ready-made solutions
And here is my opinion as long as a serious problem. I expected much more from the example widgets. When I needed a datepicker, I was forced to take the calendar component of the Sun examples and a bit of him converting to create a custom control containing a textbox and a button that displays a calendar. Augurs well for the future collection of JFXtras , but so far it's still too little.
support from the IDE
At once I said my favorite is the Eclipse environment. Unfortunately - at this stage to fight with the JavaFX had any sense, I had to change to (tymczasowo! right back!) For Netbeans 6.5. I do not want to offend fans of NB, so I will not elaborate on the obvious differences of these environments, which for obvious reasons (obvious obviousness) hamper my job;) Netbeansowy JavaFX plugin is also not error free, and the most troublesome concern prompting, organizing imports and formatting code. Refactoring does not work also (horror of horrors), and various means of navigation in the code (eg, call hierarchy, which happens often used).
Future
JavaFX is still a new technology that requires okrzepnięcia, stabilize, and strong support from the community . Sun should also place greater emphasis on the creation of ready-made libraries of components, effects, and "gadgets" that would make it easier to start building the complex, good-looking web applications. JavaFX is still firmly
changes - you can see it even after the examples found in the network, some of which simply does not work anymore, due to changes in API. The idea, however, is undoubtedly an interesting and promising, so fingers crossed for the technology:)