Reputation: 1616
I tested this code to create a stage with tabs:
public void GeneralConfiguration()
{
Stage configurationStage = new Stage();
configurationStage.setTitle("General Settings");
configurationStage.initModality(Modality.WINDOW_MODAL);
Group grid = new Group();
TabPane tabPane = new TabPane();
//Create Tabs
Tab tabA = new Tab();
tabA.setText("Main Component");
tabA.setClosable(false); // da se mahne opciqta da se zatvarq tab
//Add something in Tab
StackPane tabA_stack = new StackPane();
tabA_stack.setAlignment(Pos.CENTER);
tabA_stack.getChildren().add(new Label("Label@Tab A")); // dobavq se tuka accordion
tabA.setContent(tabA_stack);
tabPane.getTabs().add(tabA);
Tab tabB = new Tab();
tabB.setText("Second Component");
tabB.setClosable(false); // da se mahne opciqta da se zatvarq tab
//Add something in Tab
StackPane tabB_stack = new StackPane();
tabB_stack.setAlignment(Pos.CENTER);
tabB_stack.getChildren().add(new Label("Label@Tab B"));
tabB.setContent(tabB_stack);
tabPane.getTabs().add(tabB);
Tab tabC = new Tab();
tabC.setText("Last Component");
tabC.setClosable(false); // da se mahne opciqta da se zatvarq tab
//Add something in Tab
StackPane tabC_vBox = new StackPane();
tabC_vBox.setAlignment(Pos.CENTER);
tabC_vBox.getChildren().add(new Label("Label@Tab C"));
tabC.setContent(tabC_vBox);
tabPane.getTabs().add(tabC);
//grid.add(tabPane);
grid.getChildren().add(tabPane);
// Configure dialog size and background color
Scene Scene = new Scene(grid, 800, 600, Color.WHITESMOKE);
configurationStage.setScene(Scene);
configurationStage.show();
}
Can you tell me how I can fill the stage with the tabs body. Now I get this result:
Upvotes: 0
Views: 690
Reputation: 1760
Don't put the tab pane into a grid. You can put it directly into the scene like:
Scene Scene = new Scene(tabPane, 800, 600, Color.WHITESMOKE);
And now you have all the tab pane adjusted to the size of the scene.
Hope it helps!
Upvotes: 3