Reputation: 415
I'm very new to Javafx and I'm facing a problem right now. I want to add controls into a borderpane. So I did this:
borderPane.setLeft(label1);
And when I try placing another label beside label1
, I did this:
borderPane.setLeft(label2);
But it replaces label1
. I want them to be side by side. How should I do that?
Upvotes: 1
Views: 1744
Reputation: 36792
You can't add two controls in a single space of BorderPane
. If you need to add multiple controls you need to use a Container, such as a HBox.
Add both labels to it, and then add the HBox to the left side of the BorderPane.
HBox box = new HBox();
box.getChildren.addAll(label1, label2);
borderPane.setLeft(box);
Upvotes: 2