Java Reference
In-Depth Information
circle.scaleY = 1.25;
}
onMouseExited:function(e:MouseEvent){
circle.scaleX = 1.0;
circle.scaleY = 1.0;
}
}
}
}
Now, to use the custom node, we simply place it in the scene graph like any other node.
Scene {
content: [
MessageButton {xloc:100 yloc:100 size:50
message:"Hello, World!"}
MessageButton {xloc:200 yloc:100 size:100
message:"We've Made It!"}
]
}
This would create two buttons as shown in the next figure:
How it works...
To create a customized node, you simply extend the abstract class CustomNode . As you may
have guessed, CustomNode is a special class recognized by the JavaFX scene graph engine.
You must implement (and override) function create():Node in your node class. During
the rendering of the scene, the engine will invoke this function to get an instance of a node
that represents your custom component to be rendered.
In our example, the create() method returns an instance of class Group , a generic
container node that lets you create a branch of leaf nodes (sub-tree) to be attached to a scene
graph. Grouping your nodes allows you to treat all node members of the group as one unit. In
our example, we define two mouse event handlers ( onMouseEntered and onMouseExited )
on the group. Therefore, all members of the group will respond to the mouse events.
 
Search WWH ::




Custom Search