print JavaFX Graph - Java JavaFX

Java examples for JavaFX:Shape

Description

print JavaFX Graph

Demo Code


//package com.java2s;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;

public class Main {
    public static void printGraph(Node root) {
        printGraph(root, "");
    }//from   w  w  w. j  ava 2  s.  co  m

    private static void printGraph(Node root, String indent) {
        System.out.println(indent + root);
        if (root instanceof Button) {
            Button b = new Button();
            System.out.println(indent + "  Armed:" + b.isArmed());
            System.out.println(indent + "  Cancel:" + b.isCancelButton());
            System.out.println(indent + "  Default:" + b.isDefaultButton());
            System.out.println(indent + "  Disable:" + b.isDisabled());
            System.out
                    .println(indent + "  Focus:" + b.isFocusTraversable());
            System.out.println(indent + "  Hover:" + b.isHover());
            System.out.println(indent + "  Managed:" + b.isManaged());
            System.out.println(indent + "  Visible:" + b.isVisible());
        }
        if (root instanceof Parent) {
            indent += "  ";
            for (Node child : ((Parent) root).getChildrenUnmodifiable()) {
                printGraph(child, indent);
            }
        }
    }
}

Related Tutorials