Search code examples
javajavafxnodelistjfoenix

JavaFx JFoenix horizontal JFXNodesList


I am trying to make the node list open horizontally but it open as vertically. Is there anyway to achieve this? Thanks.

JFXNodesList buttonsNode=new JFXNodesList();
JFXButton val1=new JFXButton("1") ;
JFXButton val2=new JFXButton("2") ;
JFXButton val3=new JFXButton("3") ;

buttonsNode.addAnimatedNode(val1);
buttonsNode.addAnimatedNode(val2);
buttonsNode.addAnimatedNode(val3);

Solution

  • You have to rotate the JFXNodesList with setRotate(). The rotation occurs clockwise:

     0           down (default)
     90          left
     180         up
     270 (-90)   right
    

    Of course, all interjacent values are also possible.

    Example:

            JFXNodesList buttonsNode = new JFXNodesList();
            buttonsNode.setRotate(-90); // to the right 
            JFXButton val1 = new JFXButton("1") ;
            JFXButton val2 = new JFXButton("2") ;
            JFXButton val3 = new JFXButton("3") ;
            val1.setStyle("-fx-background-color: salmon");
            val2.setStyle("-fx-background-color: lightblue");
            val3.setStyle("-fx-background-color: lightgreen");
            buttonsNode.addAnimatedNode(val1);
            buttonsNode.addAnimatedNode(val2);
            buttonsNode.addAnimatedNode(val3);
    

    This results in:

    enter image description here

    A good blueprint for the usage of the JFXNodesList is the source code of the JFoenix-demo. Download the source code JFoenix-master.zip from https://github.com/jfoenixadmin/JFoenix. You can find the Java class for the JFXNodesList-demo at JFoenix-master\demo\src\main\java\demos\components\NodesListDemo.java.