2 Replies Latest reply: Dec 4, 2012 10:01 AM by csh RSS

    TilePane causes a gap in a HBox

    csh
      Hi,

      I need/want to place a TilePane in a HBox. But the HBox is higher than it needs to be. There is a gap of about 10 pixels at the bottom of the HBox.
      If I use VBox, it doesnt appear, but I need a HBox.

      Can I avoid that?

      Sample:
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.TilePane;
      import javafx.scene.layout.VBoxBuilder;
      import javafx.stage.Stage;
      
      
      public class TestApp4 extends Application {
      
          public static void main(String[] args) {
              launch(args);
          }
      
          @Override
          public void start(final Stage stage) throws Exception {
              HBox root = new HBox();
              root.setStyle("-fx-border-color:red");
      
              TilePane tilePane = new TilePane();
      
              tilePane.getChildren().addAll(new Button("Test"), new Button("Long Text"));
      
              root.getChildren().add(tilePane);
      
              Scene scene = new Scene(VBoxBuilder.create().children(root).build());
              stage.setScene(scene);
              stage.show();
          }
      }
        • 1. Re: TilePane causes a gap in a HBox
          James_D
          The TilePane appears to be adding space for an extra row; not exactly sure why. Try adding the controls directly to the HBox and you'll see the space disappears. Try adding TextAreaBuilder.create().prefRowCount(10).prefColumnCount(20).build() to the TilePane as well as the buttons and you'll see way more extra space.

          Calling either tilePane.setMinHeight(0); or root.setMinHeight(0); fixes the problem in the code you provided - I'm not sure I understand exactly what layout the TilePane is doing here that causes the extra space, so you may need to investigate further.
          • 2. Re: TilePane causes a gap in a HBox
            csh
            Thanks, that works for me, too. I reported a bug nonetheless.