1 Reply Latest reply on Apr 28, 2012 9:01 PM by rkolar02

    Do layout only once

    rkolar02
      I have following code. Idea is to do layout just once - center Text component and then leave text component always at same place.
      It does not work, no layout processing was ever done, loading text is at position 0,0.

      /** create loading screen */
      private Node loadingScreen(Scene scene) {
           /* construct loading ... screen */
      StackPane stack = new StackPane();
      stack.setPrefSize(scene.getWidth(), scene.getHeight());
      stack.setId("loading-screen");
      /* add text */
      Text t = TextBuilder.create().text("Loading ...").id("loading").build();
      stack.getChildren().add(t);
      stack.layout();
      t.setManaged(false);
      return stack;
      }
        • 1. Re: Do layout only once
          rkolar02
          I reworked this a bit, but text is not in centre. It is shifted to right, there must be some trick in layout computing but i do not have source code for jfx.


          Text t = TextBuilder.create().text("Loading ...").id("loading").build();
          t.setManaged(false);
          t.setX(0);
          t.setY(0);
          t.setLayoutY(scene.getHeight()/2);
          t.setLayoutX((scene.getWidth()-t.getBoundsInLocal().getWidth())/2);
          stack.getChildren().add(t);