import tornadofx.*
class MainController: Controller(){
val outPath= stringProperty(File("").absolutePath) //导出目录,默认为当前目录
val outNums= intProperty(5) //导出目录次数
}
将控制器注入视图view中,在view中增加如下代码:
代码语言:txt复制
private val c by inject<MainController>()
新建设置视图,提供对相关参数进行设置的窗口
代码语言:txt复制
import javafx.scene.layout.Priority
import tornadofx.*
class SettingView : View("设置") {
private val c by inject<MainController>()
override val root = borderpane {
center = vbox(5) {
hbox(5) {
label("导出目录:")
textfield(c.outPath) {
hgrow = Priority.ALWAYS
}
}
hbox(5) {
label("导出次数:")
combobox(c.outNums, (1..100 step 2).toList())
}
}
setPrefSize(500.0, 500.0)
paddingAll = 10.0
style {
fontSize = 16.px
}
}
}