How to resize an image when resizing the window in JavaFX

前端 未结 4 1486
-上瘾入骨i
-上瘾入骨i 2020-11-30 10:58

I want an image to be resized automatically when the user drags the main window. Is that possible?

I have the following code that sets a window of a certain size. It

4条回答
  •  盖世英雄少女心
    2020-11-30 11:28

    Are you looking to resize an actual image, or just to center it?

    You can try this: VBox.setVgrow(root, Priority.ALWAYS); and see if that's what you want.

    Also, be careful with you image, because it's a png image. I'm a bit skeptic regarding what's resized there (the actual image or the transparent background).

提交回复
热议问题