我尝试了几种方法:
tabPane.getSelectionModel().selectedItemProperty().addListener((e, o, n)
if (tabPane.getTabs().isEmpty()) someButton.setDisable(false);
这在创建选项卡时:
tab.setOnCloseRequest(e ->
if (tabPane.getTabs().isEmpty()) someButton.setDisable(false);
但两者都不起作用。第二种方法绝对是错误的,因为它在实际关闭选项卡之前检查是否有选项卡。任何解决方案?非常感谢
isNotEmpty BooleanBinding
在 TabPane 上创建ObservableList<Tab>
。
TabPane tp = new TabPane(new Tab("A"),new Tab("B"));
final BooleanBinding empty = Bindings.isNotEmpty(tp.getTabs());
Button someButton = new Button();
someButton.disableProperty().bind(empty);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句