Marc Rasmussen
Marc Rasmussen

Reputation: 20565

Adding several nodes as TabPane content

I am currently trying to add some content to a tabPane with the method:

tab.setContent(label, combobox);

Sadly this method only allows me to add 1 component to my tab so how do I work around this limitation? Do I need to create a new class and add that stage as a component or is there another way?

Update:

I'm sorry my original question was not clear enough here is a brief explanation:

So I've created my GUI in JavaFx Scene builder and i have created a tabPane where i have three different tabs. All of which needs to contain different things now depending on which button you click on in my GUI i want to change the content of the tabs therefore i need to write the code my self my.

My problem is that i want to add components to my tab manually yet i am unable to because the tab.setContent method allows me to only add 1 component! also i am unable to set the component where i want it to be it kinda stays in the top left corner!

Upvotes: 0

Views: 2240

Answers (1)

Sergey Grinev
Sergey Grinev

Reputation: 34528

Use any layout manager as content:

FlowPane pane = new FlowPane();
pane.getChildren().addAll(new Label("Hello"), new Label(", world"));
tab.setContent(pane);

Upvotes: 3

Related Questions