gpt4 book ai didi

JavaFX 选项卡将进度指示器设置为标题

转载 作者:行者123 更新时间:2023-12-03 16:19:16 26 4
gpt4 key购买 nike

我在 JavaFX 中使用 TabPane 并在任务运行时创建它们。任务完成后,我将选项卡与包含任务结果的新选项卡交换。
我想在选项卡的标题中显示一个加载微调器(javaFX 术语:进度指示器)。
那可能吗?
像这样:
enter image description here

最佳答案

是的,可以只使用 tab.setGraphic(...);

/**
* <p>Sets the graphic to show in the tab to allow the user to differentiate
* between the function of each tab. By default the graphic does not rotate
* based on the TabPane.tabPosition value, but it can be set to rotate by
* setting TabPane.rotateGraphic to true.</p>
*/
public final void setGraphic(Node value) {
graphicProperty().set(value);
}
完整的可运行示例:
public class Main extends Application {

@Override
public void start(Stage primaryStage) throws Exception {

ProgressIndicator progressIndicator = new ProgressIndicator();

Tab tab = new Tab();
tab.setClosable(false);
tab.setGraphic(progressIndicator);

TabPane tabPane = new TabPane(tab);
tabPane.setPrefSize(200,200);

primaryStage.setScene(new Scene(tabPane));
primaryStage.show();
}
}

关于JavaFX 选项卡将进度指示器设置为标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67125725/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com