简体   繁体   English

如何通过单击 TornadoFX 中的按钮来加载图像?

[英]How to load image by clicking on button in TornadoFX?

It works this way, but it puts the image in the button.它以这种方式工作,但它将图像放在按钮中。 Also I need to manipulate the image later, so somehow I need to save it in an Image variable.我还需要稍后操作图像,所以我需要以某种方式将其保存在 Image 变量中。

class MainView : View("FilterApp") {

override val root = vbox {
    val inputTextField = textfield { }
    var imageBox = imageview(){}

    button("Click me") {
        action {
            imageBox = imageview(Image(inputTextField.getText()))
        }
    }
}
}

got it知道了

class MainView : View("FilterApp") {

private lateinit var mainImage: Image

override val root = vbox {
    val inputTextField = textfield { }
    var imageBox = imageview(){}

    button("Click me!") {
        action {
            mainImage = Image(inputTextField.getText())
            imageBox.image = mainImage
        }
    }
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM