JavaFX / CSS:“-fx-background-radius:10;”拧我的背景

时间:2019-04-21 06:17:31

标签: java css javafx background

我正在游戏中动态创建一些VBox,以显示较小版本的卡。为此,我为VBoxes设置了背景(对象背景)。

当尝试在CSS中对其进行样式设置时,它实际上可以正常工作,但是当尝试使用“ -fx-background-radius:10;”来解决问题时,它实际上不再显示背景。

我认为这与创建背景的方式有关:

public Background getBackground(Boolean isOwnCard, Card card) {
    String fileName = card.getCardType().toString();
    BackgroundSize bgs;

    if (isOwnCard) {
        bgs = new BackgroundSize(110, 50, false, false, false, false);
    } else {
        bgs = new BackgroundSize(75, 50, false, false, false, false);
    }

    BackgroundImage bgi = new BackgroundImage(new Image("file:client.Resources/Images/CardImageSmall/" + fileName + ".jpg"), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, bgs);
    Background bg = new Background(bgi);
    return bg;
}

在CSS中使用-fx-background-radius: 10;

Image of without the "-fx-background-radius: 10;" in CSS

在CSS中没有-fx-background-radius

Image with the background radius in CSS the background

是否有可能绕过背景的角落?有人遇到过同样的问题吗?

编辑

我已经尝试过在CSS中设置背景,但是遗憾的是背景仍然不想弄圆角:

#CardImageSmallBrown{
    -fx-background-image: url('../../client.Resources/Images/CardImageSmall/BRAUN.jpg"');
    -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 0);
    -fx-background-radius: 50px;
    -fx-border-radius: 50px;
    -fx-border-width: 5px;
    -fx-border-color: black;
    -fx-background-position: center;
}

结果:

image of result with CSS

如何修整背景的边缘!?

0 个答案:

没有答案