我测试了这段代码,创建了一个带标签的舞台:
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();
}
你能告诉我如何用标签体填充舞台。现在我得到了这个结果:
答案 0 :(得分:3)
不要将标签窗格放入网格中。您可以将其直接放入场景中,如:
Scene Scene = new Scene(tabPane, 800, 600, Color.WHITESMOKE);
现在,您可以将所有选项卡窗格调整为场景大小。
希望它有所帮助!