简体   繁体   English

如何在 tornadofx 的 ImageView 中加载固定大小的图像

[英]How to load an image with fixed size in tornadofx's ImageView

When I'm using JavaFX, Image with the tornadofx, everything works, but it's not async.当我使用 JavaFX,带有 tornadofx 的图像时,一切正常,但它不是异步的。

imageview {
    image = Image(url, 200.0, 200.0, false, true)
}

so I'd like to do it the native tornadofx way, but I'd like to resize it as well.所以我想用原生的 tornadofx 方式来做,但我也想调整它的大小。

imageview(url, 200.0, 200.0, false, true)

this constructor doesn't exist, but I can't really resize it, as there's no setHeight and setWidth methods I could use (at least I can't see them).这个构造函数不存在,但我不能真正调整它的大小,因为没有我可以使用的 setHeight 和 setWidth 方法(至少我看不到它们)。

I solved it like this, but I'm not sure if this is the best way to do it.我像这样解决了它,但我不确定这是否是最好的方法。

setPrefSize(100.0, 100.0)
imageview(url) {
    fitHeightProperty().bind(parent.prefHeight(100.0).toProperty())
    fitWidthProperty().bind(parent.prefWidth(100.0).toProperty())
}

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

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