Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Kotlin刷新图像视图_Java_Android_Kotlin_Desktop Application_Tornadofx - Fatal编程技术网

Java Kotlin刷新图像视图

Java Kotlin刷新图像视图,java,android,kotlin,desktop-application,tornadofx,Java,Android,Kotlin,Desktop Application,Tornadofx,我试图刷新按钮叮当声中imageview的图像,但它似乎不起作用。 这是我的密码: class MasterView : View("Master View") { val controller: MyController by inject() val currentenemy = SimpleIntegerProperty(0) override val root = borderpane() { right = imagevie

我试图刷新按钮叮当声中imageview的图像,但它似乎不起作用。 这是我的密码:

class MasterView : View("Master View") {
    val controller: MyController by inject()
    val currentenemy = SimpleIntegerProperty(0)

    override val root = borderpane() {
        right = imageview(controller.monsters[currentenemy.value]) {
            setFitHeight(250.0)
            setFitWidth(175.0)
        }
        center = button("Change image") {
            action { currentenemy.value += 1 }
        }
    }
}

我知道值在变化,但imageview似乎并不关心它。

我不太明白它为什么会修复它,但我尝试将该值放入SimpleStringProperty中,并将该变量传递给imageview,现在在按钮单击时更新它

val simplestring = SimpleStringProperty("slime.png")
...
imageview(observablepic)
center = button("Change image") {
    action { 
        currentenemy.value += 1 
        simplestring.value = controller.monsters[currentenemy.value]
    }
}
...
val simplestring = SimpleStringProperty("slime.png")
...
imageview(observablepic)
center = button("Change image") {
    action { 
        currentenemy.value += 1 
        simplestring.value = controller.monsters[currentenemy.value]
    }
}
...
class MyController: Controller() {
    val monsters = FXCollections.observableArrayList("slime.png", "goblin.png", "mage.png", "knight.png", "boss.png")
}