Forum Stats

  • 3,727,999 Users
  • 2,245,515 Discussions
  • 7,853,236 Comments

Discussions

Widgets on FXCanvas doesnt display

I am trying to write an application in eclipse. So as to use javafx components on components am using the FXCanvas. So the problem is i try the below program which creates around 500 nodes, the composite is empty. And none of the nodes are displayed.

But instead of 500 nodes, if we create 50 nodes, then the nodes are visible in the SWT Composite.

What is the problem here ?

FXCanvas canvas = new FXCanvas(swtComposite, SWT.NONE) {

      @Override

      public Point computeSize(final int wHint, final int hHint, final boolean changed) {

        getScene().getWindow().sizeToScene();

        int width = (int) getScene().getWidth();

        int height = (int) getScene().getHeight();

        return new Point(width, height);

      }

    };

    Group group = new Group();

    Scene scene = new Scene(group);

    canvas.setScene(scene);

    VBox container = new VBox();

    ScrollPane root = new ScrollPane(container);

    root.setContent(container);

    for (int i = 0; i < 500; i++) {

      container.getChildren().add(new Button("Hello_" + i));

    }

    group.getChildren().add(container);

Sign In or Register to comment.