4

I cannot find a way to align tabs in a JavaFX TabPane. Let's say we take the following example:

TabPane tabPane = new TabPane();
Tab tab1 = new Tab();
Tab tab2 = new Tab();

tabPane.add(tab1);
tabPane.add(tab2);

How can I align tab1 to the left and tab2 to the right of the tabPane? It does not matter to me if this is done in Java code or in CSS.

n00b1990
  • 1,189
  • 5
  • 17
  • 25
  • You want one tab on the left and the other on the right side of the same tabpane ? – ItachiUchiha May 27 '14 at 09:34
  • Is it not just the order you add the tabs to the tab pane? – Cobbles May 27 '14 at 20:37
  • No, because I want to take 3 tabs and align them to the left, and 3 other tabs to the right, leaving a space in between them. I did think about a "empty" tab in the center, setting the width to create the same effect, but setting the width is not possible. For me then, because I found no way of doind this – n00b1990 May 28 '14 at 07:51
  • I know it is an old question, but since it has several upvotes, please see my answer here: http://stackoverflow.com/questions/37284366/javafx-tab-pane-with-multiple-rows/37321875#37321875 With this approach you can align the tabs (ToggleButtons) as you want. – DVarga May 27 '16 at 18:35

1 Answers1

0

You could use Scene Builder or FXML to build your Tabs its is easy as well as less error prone and you can align it the way you want and if you have constraints and have to do it from java code you can use a combination of HBox and VBox and set it to the scene.

Rahul Singh
  • 19,030
  • 11
  • 64
  • 86