首页 > 解决方案 > JavaFX SceneBuilder 样式表

问题描述

我目前正在尝试通过 SceneBuilder 将样式表添加到我的场景中,但是目前我似乎遇到了一些问题。

-fx-background-color:

        linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%),
        linear-gradient(#020b02, #3a3a3a),
        linear-gradient(#9d9e9d 0%, #6b6a6b 20%, #343534 80%, #242424 100%),
        linear-gradient(#8a8a8a 0%, #6b6a6b 20%, #343534 80%, #262626 100%),
        linear-gradient(#777777 0%, #606060 50%, #505250 51%, #2a2b2a 100%);

目前我正在尝试使用该段为HBox我的Scene.

如果需要,看看我的 FXML:

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <bottom>
      <HBox stylesheets="@styles/bottomRow.css" BorderPane.alignment="CENTER">
         <children>
            <Label fx:id="nameOfImage" text="nameOfImage" />
            <Region HBox.hgrow="ALWAYS" />
            <Label fx:id="sizeOfImage" text="sizeOfImage" />
         </children>
         <opaqueInsets>
            <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
         </opaqueInsets>
         <padding>
            <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
         </padding>
      </HBox>
   </bottom>
   <top>
      <VBox BorderPane.alignment="CENTER">
         <children>
            <MenuBar>
              <menus>
                <Menu mnemonicParsing="false" text="File">
                  <items>
                    <MenuItem mnemonicParsing="false" text="Close" />
                  </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Edit">
                  <items>
                    <MenuItem mnemonicParsing="false" text="Delete" />
                  </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Help">
                  <items>
                    <MenuItem mnemonicParsing="false" text="About" />
                  </items>
                </Menu>
              </menus>
            </MenuBar>
         </children>
      </VBox>
   </top>
   <center>
      <HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
         <children>
            <Region prefHeight="200.0" prefWidth="200.0" />
            <ImageView cacheHint="SCALE" depthTest="ENABLE" fitHeight="150.0" fitWidth="200.0" nodeOrientation="INHERIT" pickOnBounds="true" preserveRatio="true" HBox.hgrow="ALWAYS">
               <viewport>
                  <Rectangle2D />
               </viewport>
            </ImageView>
            <Region prefHeight="200.0" prefWidth="200.0" />
         </children>
      </HBox>
   </center>
</BorderPane>

我之前设法使用线性渐变,但是我不确定这里出了什么问题。目前它应该给它上色,HBox但目前它留下一个白色的石板,没有一丝颜色。我试图找到更好的方法来.css查看该部分是否正确,但它们或多或少看起来都一样。

以为我会发布最后一点以防万一: 图像的东西

标签: cssjavafxscenebuilder

解决方案


推荐阅读