Hello user, Javafx 2.0 has more efficient code because it has mother language of Java. Previous javafx was script language which has very easier coding steps but that script language has more performance issue so Oracle has planned to move it on Java as Swing 2.0. Ok now let’s move toward the new shapes feature of javafx 2.0 (in context of beta release).


Shapes Union

To make some kind of shapes union you can easily make them from the help of Shape and Path class. So lets have a small demo of Union in javafx. Math Sets: It is some thing like A={1,2,3,4} B={3,4,5,6} then if we use AUB = {1,2,3,4,5,6}. We ‘ll use the union between shapes from this function union(shape,shape)

Union Output



Shapes Subtract

Now the Subtract shape is also some how same like of Union. It removes the part of any one of Shapes completely using function subtract(shape,shape). It complies the rule of sets. Like A={1,2,3,4} B={3,4,5,6} then if we use A-B = {1,2}. Lets have a look on subtract of Shapes example too.

Shape Subtract


Shapes Intersects

The intersects takes the common overlapping of all the circle(shapes). For shapes intersects we can use the intersect(shape,shape) function of Path class. It is some thing like A={1,2,3,4} B={3,4,5,6} then if we use A∩B = {3,4}

public Scene getUI(){ 

//Main panel

Group panel = new Group();

//Main scene

Scene scene = new Scene(panel,300,300);

//Creating Three Circles Shapes

Circle c1 = new Circle();





Circle c2 = new Circle();





Circle c3 = new Circle();





//intersect function which intersects any two shapes

Path path = Path.intersect(c1, c2);

//Now again intersect same path with c3 Circle

//because Path is subclass of Shape as well

path = Path.intersect(path, c3);



return scene;


Shapes Intersect

Feel free to comment.

Have a 🙂 good day!