May 14
Tools, Tools, Tools! Would scream the learned developer. Without tools, a great language is nothing. With tools, a moderate language can take over the market.
Granted, JavaFX is fresh out of the oven, and it does provide us with Eclipse and NetBeans plugins (which I haven’t tested myself yet) but what we need to see here is a set of tools, not just one or a plugin, which would help designers create amazing graphical experiences, would help developers bind between their current complex data models, and which would help to graphically bind between data model elements and graphical interface elements.
What I am waiting to see is essentially a JavaFX version of Interface Builder or Expression, along side with all the plugins which will become available with time.
May 12
This is a really simple thing I wrapped up in a couple of minutes. It doesn’t show much, and certainly isn’t very flashy, but it does show some main points I wanted to share about my 5-minutes experience with JFX.
By the way, this code can be just taken as is and put directly into the JavaFX Pad.
import javafx.ui.*;
import javafx.ui.canvas.*;
class Person {
attribute name:String ;
attribute parent:Person inverse Person.children;
attribute children:Person* inverse Person.parent;
attribute gender:String;
}
Canvas {
var father = Person { name:"George", gender:"Male" }
var jen = Person {name:"Jennifer", parent:father, gender: "Female" }
var matt = Person { name:"Matt", parent:father, gender:"Male" }
var lara = Person {name:"Lara", parent:father, gender: "Female" }
content: select Text {content: p.name y:indexof p * 15}
from p in father.children
where p.gender == "Female"
}
The points I want to show off:
- No need to update the “children” attribute: Notice that I do not update the
children attribute of dad. Since children and parent are defined to be inverse to one another, just specifying who the parent is is enough.
- Creating graphical elements is easy: I can create graphical elements using a
select statement on the array of items I have in my data model, and use their attributes as values to the elements. It’s that simple – I create three elements here with one line of code, and I could create complex queries using joins and where clauses.
The annoying part was when I tried to give some behavior to the generated Text elements. I changed the creation to be like this:
Text {
var x1:Number = 0
var y1:Number = indexof p * 15 + 20
content: p.name
x:bind x1
y:bind y1
cursor:HAND
onMouseDragged:operation(e:CanvasMouseEvent) {
x1 += e.localDragTranslation.x;
y1 += e.localDragTranslation.y;
}
But, it didn’t work! It did change the cursor to “Hand” when the mouse was over an element, but it didn’t make the drag work. I can’t imagine why – In an example on the openjfx.org site something similar was made, but there they used subclassing and adding attributes instead of adding variables dynamically like I chose to do here. Maybe that’s the case; but it really isn’t clear. If anyone has an idea, please let me know!
May 12
I want to say “Amazing”, but there are some hic-ups that still bother me yet with it, at least to the extent of my understanding of the JavaFX framework. As something that has only been announced recently, there is very little information about it still, however I gather my knowledge from the official site’s Language Reference, because that is what I’ll be writing about today (and not the cool animations and fade-outs you can do with it, not even about the Motorola site recreated using JavaFX)
So, just to summarise it for those two haven’t been paying attention, Sun has announced a competitor to Flash, even though that’s not what they’re saying. They are saying, though, that it is a tool to easily create rich graphical user experience, which will leverage Java’s key feature: Write-once-run-everywhere. That means that Sun aren’t just bringing into the field another Flash competitor – They are bringing it everywhere, and they’re starting with mobile phones.
Now to the features of the language. JavaFX is nothing like Java. First, it’s a scripting language aimed at rich graphical experience, and not for business workflow management. Second, it’s not type safe in almost any fashion possible – with the advantages and disadvantages of that. There is var, and it infers its type from its use.
These two factors, I believe, are key to the additions in this feature-savvy scripting language, and I will enumerate the ones I like best: Continue reading »