Using Group in JavaFx

Using Group in JavaFx:
Group in JavaFx can be used to put multiple nodes together in order and then later use it as one. Any effect applied to the group will be applied to all the children nodes.
For example:

 var bgRect = Rectangle
 {
   width: 20,
   height: 20,
   arcHeight: 5;
   arcWidth: 5;
   fill: Color.CYAN
 }

 var pageTxt = Text
 {
   font: Font
   {
      size: 15
   }

 content: pageString;

 }

 var pageNoGrp = Group
 {
   content:
   [
     Stack
     {
        content:
         [
           bgRect,
           pageTxt
         ]
     }
   ]
 }

The variable pageNoGrp is a group that contains a stack of bgRect node and pageTxt node.  It will have a background rectangle of specified dimensions and the pageTxt is stacked on top of the rectangle.

The output is looks like:

Here the pagetext zero(0) is stacked on top of rectange.

 

 

Advertisements