我需要显示的图像的宽度/高度在imegView并将其与原单图像尺寸,该尺寸在imageView.getImage()。的getWidth()/的getHeight(),并且如果用户调整其大小形成应用GUI听变化。如何获得在javafx imageView中显示图像的宽度/高度?
我从imageView.fitWidthProperty()
这个大小和高度相似,但我得到在它的ImageView的不是图像尺寸:
我得到蓝色的大小是ImageView的,但我需要显示的图像的大小(绿色) 。我怎样才能得到它作为属性来监听用户调整窗口应用程序的大小(绿色也改变大小,但它似乎有最大和最小大小,所以它停止与最大或最小的imageView调整大小)。
我使用这个属性来计算原单图像的大小%以下蓝色矩形右下角。
可能吗?
E:下面是此标签的FXML:
<BorderPane fx:id="root" fx:controller="..."
xmlns:fx="..." xmlns="..." stylesheets="@...css">
<center>
<StackPane>
<ImageView fx:id="..."/>
<fx:include source="...fxml" fx:id="..."/>
</StackPane>
</center>
<bottom>
<VBox fx:id="..." minHeight="110" styleClass="small-padding" spacing="5">
<HBox alignment="CENTER_RIGHT" spacing="5">
<fx:include source="...fxml" resources="..."
fx:id="..."/>
</HBox>
<TextArea fx:id="..." promptText="%..." styleClass="-fx-description-text-area"/>
</VBox>
</bottom>
imageView.getFitWidth()不起作用。但我发现我需要imageView.boundsInParentProperty()所以问题解决了。 – xav9211