TornadoFX 获取对选项卡的引用并获取其 Stage
TornadoFX get reference to a tab and get its Stage
如何获取对第一个选项卡的引用?此外,我如何获得它的 Stage?
class MainApp : App() {
override val primaryView = MainView::class
class MainView : View() {
override val root = VBox()
init {
with(root) {
tabpane {
tab("Report") {
hbox {
// TODO Want a reference to this tab here.
// Ideally something like tab.getStage()
this += Button("Hello 1")
}
}
tab("Data Entry") {
hbox {
this += Button("Hello 2")
}
}
}
}
}
}
}
Quickly:我在这里看到了很多你的帖子,它们都是非常基本的问题。如果你自己挖掘,这些是你可以自己弄清楚的事情。我建议 至少 查看 official guide 以很好地掌握您需要了解的大部分内容。然后,查看此处的其他帖子,看看它们是否已得到答复。
但是要回答你的问题:
class MainView : View() {
override val root = vbox {
tabpane {
tab("Report") {
hbox {
val tab = this@tab //Here is your tab
button("Hello 1")
}
}
tab("Data Entry") {
hbox {
button("Hello 2")
}
}
}
}
}
再次,我建议您查看该指南,因为您错过了一些有用的构建工具(看看我是如何构建按钮的?看看我是如何将根移出 init 的?)。我不希望你编写的代码比你需要的多,然后你会意识到,如果你知道怎么做的话,你可以做更少的工作。
另外:选项卡没有对阶段的引用。它们只是继承了 Styleable 和 EventTarget,它们不像 Views 或 Fragments。
如何获取对第一个选项卡的引用?此外,我如何获得它的 Stage?
class MainApp : App() {
override val primaryView = MainView::class
class MainView : View() {
override val root = VBox()
init {
with(root) {
tabpane {
tab("Report") {
hbox {
// TODO Want a reference to this tab here.
// Ideally something like tab.getStage()
this += Button("Hello 1")
}
}
tab("Data Entry") {
hbox {
this += Button("Hello 2")
}
}
}
}
}
}
}
Quickly:我在这里看到了很多你的帖子,它们都是非常基本的问题。如果你自己挖掘,这些是你可以自己弄清楚的事情。我建议 至少 查看 official guide 以很好地掌握您需要了解的大部分内容。然后,查看此处的其他帖子,看看它们是否已得到答复。
但是要回答你的问题:
class MainView : View() {
override val root = vbox {
tabpane {
tab("Report") {
hbox {
val tab = this@tab //Here is your tab
button("Hello 1")
}
}
tab("Data Entry") {
hbox {
button("Hello 2")
}
}
}
}
}
再次,我建议您查看该指南,因为您错过了一些有用的构建工具(看看我是如何构建按钮的?看看我是如何将根移出 init 的?)。我不希望你编写的代码比你需要的多,然后你会意识到,如果你知道怎么做的话,你可以做更少的工作。
另外:选项卡没有对阶段的引用。它们只是继承了 Styleable 和 EventTarget,它们不像 Views 或 Fragments。