This discussion is archived
2 Replies Latest reply: Dec 4, 2012 8:01 AM by csh RSS

TilePane causes a gap in a HBox

csh Journeyer
Currently Being Moderated

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?

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) {

    public void start(final Stage stage) throws Exception {
        HBox root = new HBox();

        TilePane tilePane = new TilePane();

        tilePane.getChildren().addAll(new Button("Test"), new Button("Long Text"));


        Scene scene = new Scene(VBoxBuilder.create().children(root).build());
  • 1. Re: TilePane causes a gap in a HBox
    James_D Guru
    Currently Being Moderated
    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 Journeyer
    Currently Being Moderated
    Thanks, that works for me, too. I reported a bug nonetheless.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points