Why use Custom Node and Container? 

JavaFx has many predefined nodes and layout containers made readily available for use. Also, JavaFx provides the facility to extend custom node to create user defined node and container to create user defined layout.  Predefined nodes like imageview, rectangle, circle, groups, HBox, VBox, e.t.c are great and easy to use and provides lot of flexibility with predefined functions for the nodes. So, when to create a user defined node or user defined container?

Creating a user defined node by extending custom node allows user to add more flexibility and customization on a node.Consider a group node which has a rectangle node and a ImageView node centered within the rectangle. Now, lets say we have five such group nodes within a VBox node and the visibility of rectangle on all group within the VBox is set to false. Now using the functions defined for VBox, we can easily select each group node within it and request focus for each group node but it would be very tedious or impossible to turn the visibility of rectangle inside the group to true. This is where extending custom node comes to play. We can create a custom node with the group and rectangle and the VBox with the group and rectangle within it. Now in the custom node we can define a function which can turn the visibility of rectangle to true and false. Now using this custom node instead of just the VBox that we used  earlier, we can set the visibility of rectangle to true or false at any point or any where in the code.

Similarly a user defined container by extending container class allows user to add more flexibility and customization for laying out nodes. Using predefined layout containers like HBox, Tiles, VBox, e.t.c it is possible to create attractive and interesting layouts but the layouts are constrained. Lets say we want to develop an image gallery such that the first row displays one image, second row displays two image, third row displays three image and so on.  It is possible to create such image gallery using HBox, Tiles, or VBox but the code would look nasty and would be tedious to do so. However, by extending a container and creating a custom layout we can do so easily using the positionNode() and layoutNode() methods provided. We can easily use a for loop and within it use the positionNode() function to position the images. Also, for resizable nodes we can resize the nodes within the container.

From my perspective, extending customNode and container provides great flexibility and customization,but it is always good to use predefined nodes unless creating custom node or container is really required. It keeps the code simple and manageable. While extending custom Node or container, it is always required to override the create() function and the doLayout() function respectively.