FXML - 如何在 ChoiceBox 中预选项目?
FXML 的等效项是什么(cb 是一个 ChoiceBox):
cb.getSelectionModel().select(1);
我尝试了这样的方法:
<ChoiceBox SelectionModel.select="1">
....
</ChoiceBox>
以及
<ChoiceBox>
<SelectionModel select="1"/>
....
</ChoiceBox>
许多类似的变体,但这些都不起作用
What is the FXML equivalent for this (cb is a ChoiceBox):
cb.getSelectionModel().select(1);
I tried something like this:
<ChoiceBox SelectionModel.select="1">
....
</ChoiceBox>
and
<ChoiceBox>
<SelectionModel select="1"/>
....
</ChoiceBox>
and a lot of similar variations, but those didn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在,您必须通过 Controller 类中的 Java 代码来完成此操作。
已提交一个待处理的增强请求来处理 FXML 中的此问题。它看起来与您在这里发布的内容非常相似。
Right now, you have to do it via Java code in the Controller class.
There is a pending enhancement request already submitted to handle this in the FXML. It looks very similar to your posting here.
如果您使用场景生成器,请在 fxml 中尝试此操作。
if you using scene builder then try this in fxml.