我在可调整大小的JavaFX-Scene中设置按钮的背景图像时遇到问题 . 在调整窗口大小超过一定大小时,背景图像似乎淡出 . 在按钮中使用ImageView以及通过CSS设置背景图像时出现问题 .

我在YouTube上上传了一段视频用于演示:https://www.youtube.com/watch?v=svMemJnaax0

调整窗口大小时,您可以看到背景图像消失 . 该错误在Windows和Linux下可重现 .

它似乎只发生在一些png图标上 .

这是在调整窗口大小时的样子,当向右增加窗口大小时,右按钮中的图像向左移出按钮区域 . 只有右侧按钮受影响,左侧按钮不受影响:http://oi57.tinypic.com/20k3bqg.jpg

这是FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="288.0" prefWidth="862.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <BorderPane layoutX="45.0" layoutY="20.0" minHeight="100.0" minWidth="200.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" HBox.hgrow="ALWAYS">
         <bottom>
            <HBox alignment="TOP_RIGHT" BorderPane.alignment="CENTER">
               <children>
                  <Button mnemonicParsing="false" prefHeight="24.0" prefWidth="50.0" styleClass="googlebutton" stylesheets="@style.css">
                     <HBox.margin>
                        <Insets right="5.0" />
                     </HBox.margin>
                  </Button>
                  <Button mnemonicParsing="false" text="Button" />
                  <Button mnemonicParsing="false" prefHeight="24.0" prefWidth="50.0" styleClass="iconbutton" stylesheets="@style.css">
                     <HBox.margin>
                        <Insets left="5.0" />
                     </HBox.margin></Button>
               </children>
               <BorderPane.margin>
                  <Insets top="5.0" />
               </BorderPane.margin>
            </HBox>
         </bottom>
         <center>
            <ListView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
         </center>
         <top>
            <Label text="List" BorderPane.alignment="TOP_LEFT">
               <BorderPane.margin>
                  <Insets bottom="5.0" />
               </BorderPane.margin>
            </Label>
         </top>
         <HBox.margin>
            <Insets left="20.0" />
         </HBox.margin>
      </BorderPane>
   </children>
</AnchorPane>

而style.css:

.iconbutton {
    -fx-background-image:  url("http://s28.postimg.org/5nsybhb65/round57.png");
    -fx-background-size: 24,24;
    -fx-background-repeat: no-repeat;
}

.googlebutton {
    -fx-background-image:  url("https://www.google.de/images/google_favicon_128.png");
    -fx-background-size: 24,24;
    -fx-background-repeat: no-repeat;
}

有没有其他人遇到过这样的问题?

谢谢,Jan