JavaFX CSS按钮图形调整大小 [英] Javafx css button graphic resize

查看:418
本文介绍了JavaFX CSS按钮图形调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改按钮内图标的大小. 图像的尺寸为512 x 512,我想将尺寸调整为16x16. 因此,使用javaFX CSS实现此目标的最佳方法是什么.

I want to change the size of an icon inside a button. The image has a size of 512 x 512, i want to resize to 16x16. So, what's the best way to acheive this using javaFX CSS.

这是到目前为止我要做的事情:

Here is what i'm done until now :

#btnCancel.button {
    -fx-graphic: url("/img/close.png") ;
    -fx-graphic-size:16px 16px ; ( I think this property not exist in javafx css)

}

但这对我不起作用.

推荐答案

我不知道可以直接用于设置-fx-graphic大小的任何 css属性,但是您可以实现使用-fx-background-image属性获得相似的结果.这将允许您使用-fx-background-size设置宽度和高度值.

I am not aware of any css property that can be used directly to set the -fx-graphic's size but you can achieve similar results using -fx-background-image property. This will allow you to set width and height values using -fx-background-size.

您可以从查看实际情况

使用-fx-graphic

-fx-background-image-fx-background-size一起使用

这篇关于JavaFX CSS按钮图形调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆