VBox是一个幽灵

时间:2014-06-06 04:15:39

标签: java css javafx javafx-8 scenebuilder

我正在创建一个JavaFX桌面应用程序,而放置在StackPane中的VBox具有透明背景。我在SceneBuilder 2.0 2中创建了两个GUI,并且在SceneBuilder中VBox看起来非常好,但是一旦我将它放在StackPane中,背景变得透明。所以我想我可以在SceneBuilder / CSS中改变VBox的背景,但那并没有做任何事情。然后我想也许我可以在VBox上设置不透明度,但那也没有用。这是来自SceneBuilder的我的VBox:

enter image description here

这是我添加到StackPane时的图片:

enter image description here

以下是将添加练习对话框添加到堆栈窗格的代码:

VBox addExerciseDialog = FXMLLoader
           .load(getClass()
           .getResource("add_exercise.fxml"));
stackPaneContent.getChildren().add(addExerciseDialog);

这是stackPaneContent变量的fxml文件:

<fx:root type="StackPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <VBox fx:id="vBoxContent" stylesheets="@../multi-screens.css">
         <children>
            <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="55.0" text="Bench Press 3 x 4-6 reps" />
            <Button layoutX="10.0" layoutY="10.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="55.0" text="Leg Press 3 x 4-6 reps" />
            <Button layoutX="10.0" layoutY="65.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="55.0" text="Squats 3 x 4-6 reps" />
         </children>
      </VBox>
      <ScrollBar fx:id="scrollBar" opacity="0.0" orientation="VERTICAL" StackPane.alignment="TOP_RIGHT" />
   </children>
</fx:root>

以下是添加练习对话框的fxml:

<VBox id="add_exercise_dialog" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="159.0" prefWidth="192.0" spacing="5.0" stylesheets="@../multi-screens.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <HBox alignment="CENTER" spacing="5.0">
         <children>
            <TextField maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" promptText="Exercise" HBox.hgrow="ALWAYS" />
         </children>
      </HBox>
      <HBox alignment="CENTER" spacing="5.0" VBox.vgrow="ALWAYS">
         <children>
            <TextField layoutX="30.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="26.0" prefWidth="65.0" promptText="Sets" HBox.hgrow="SOMETIMES" />
            <TextField layoutX="18.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="0.75" promptText="Reps" HBox.hgrow="ALWAYS" />
         </children>
      </HBox>
      <TextArea maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" promptText="Notes" />
      <HBox>
         <children>
            <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Add Exercise" HBox.hgrow="ALWAYS" VBox.vgrow="ALWAYS" />
         </children>
      </HBox>
   </children>
   <padding>
      <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
   </padding>
</VBox>

这是我的css文件:

#homeIcon {
    -fx-shape: "M11,0 L0,8.50909424 L0,10.0090942 L11,1.5 L22,10.0090942 L22,8.50909424 L11,0 L11,0 Z M2,22.0090942 L6.98022461,22.0090942 L6.98022461,21.0090942 L3,21.0090942 L3,9.10784913 L2,9.91845703 L2,22.0090942 Z M19.0074464,21.0090942 L15.0289307,21.0090942 L15.0289307,22.0090942 L20.0074464,22.0090942 L20.0074463,9.88024901 L19.0074463,9.08068846 L19.0074464,21.0090942 Z M8,12 L8,22 L14,22 L14,12 L8,12 Z M9,13 L9,21 L13,21 L13,13 L9,13 Z M19,5.00909424 L20,5.86584474 L20,0.509094238 L17,0.509094238 L17,3.50909424 L18,4.38079834 L18,1.50909424 L19,1.50909424 L19,5.00909424 Z";
}

#settingsIcon {
    -fx-shape:  "M507.592,232.111c0,0-9.296-3.496-36.19-5.977c-32.884-3.04-42.804-15.365-53.742-30.709h-0.22  c-1.362-3.647-2.821-7.248-4.427-10.776l0.127-0.127c-3.122-18.58-4.812-34.316,16.292-59.719  c17.25-20.766,21.365-29.818,21.365-29.818c-4.048-10.273-13.781-20.004-13.781-20.004s-9.736-9.734-20.004-13.776  c0,0-9.052,4.104-29.818,21.361c-25.403,21.102-41.14,19.407-59.719,16.292l-0.128,0.126c-3.524-1.605-7.12-3.058-10.775-4.427  v-0.214c-15.345-10.934-27.669-20.865-30.71-53.749c-2.485-26.881-5.976-36.189-5.976-36.189C269.757,0,255.997,0,255.997,0  s-13.766,0-23.887,4.405c0,0-3.498,9.309-5.979,36.189c-3.041,32.884-15.372,42.815-30.709,53.749v0.214  c-3.647,1.369-7.25,2.821-10.776,4.421l-0.122-0.12c-18.579,3.127-34.316,4.815-59.719-16.285  C104.041,65.322,94.977,61.21,94.977,61.21c-10.273,4.053-19.992,13.771-19.992,13.771S65.25,84.724,61.208,94.99  c0,0,4.099,9.053,21.362,29.813c21.1,25.402,19.389,41.139,16.284,59.719l0.128,0.127c-1.607,3.528-3.059,7.129-4.429,10.776H94.34  c-10.927,15.35-20.859,27.669-53.741,30.709c-26.883,2.486-36.202,5.989-36.202,5.989C0.003,242.254,0.003,256,0.003,256  s0,13.771,4.405,23.887c0,0,9.297,3.503,36.185,5.978c32.883,3.041,42.803,15.38,53.747,30.71h0.214  c1.37,3.655,2.821,7.251,4.429,10.776l-0.128,0.127c3.128,18.582,4.815,34.316-16.284,59.719  c-17.252,20.765-21.368,29.829-21.368,29.829c4.059,10.268,13.775,19.993,13.775,19.993s9.742,9.736,20.01,13.771  c0,0,9.047-4.094,29.813-21.357c25.402-21.1,41.145-19.389,59.718-16.288l0.128-0.128c3.526,1.605,7.129,3.052,10.776,4.427v0.22  c15.349,10.928,27.668,20.859,30.709,53.743c2.485,26.881,5.983,36.2,5.983,36.2C242.25,512,255.997,512,255.997,512  s13.771,0,23.889-4.405c0,0,3.504-9.298,5.976-36.189c3.041-32.884,15.379-42.805,30.71-53.743v-0.22  c3.655-1.375,7.251-2.821,10.775-4.427l0.128,0.128c18.579-3.122,34.315-4.812,59.719,16.288  c20.767,17.253,29.832,21.369,29.832,21.369c10.267-4.06,19.99-13.782,19.99-13.782s9.733-9.736,13.781-20.004  c0,0-4.104-9.054-21.365-29.818c-21.104-25.402-19.403-41.137-16.292-59.719l-0.127-0.127c1.605-3.525,3.064-7.121,4.427-10.776  h0.22c10.928-15.341,20.858-27.669,53.742-30.71c26.881-2.485,36.201-5.978,36.201-5.978c4.395-10.127,4.395-23.887,4.395-23.887  S511.997,242.229,507.592,232.111z M255.997,375.727c-66.125,0-119.728-53.602-119.728-119.727s53.603-119.727,119.728-119.727  c66.124,0,119.727,53.602,119.727,119.727S322.121,375.727,255.997,375.727z";
}

.headerBar {

}

.headerBar:hover {
    -fx-background-color: white;
}

#plusIcon {
    -fx-shape: "M22.5,14H14v8.5c0,0.276-0.224,0.5-0.5,0.5h-4C9.224,23,9,22.776,9,22.5V14H0.5  C0.224,14,0,13.776,0,13.5v-4C0,9.224,0.224,9,0.5,9H9V0.5C9,0.224,9.224,0,9.5,0h4C13.776,0,14,0.224,14,0.5V9h8.5  C22.776,9,23,9.224,23,9.5v4C23,13.776,22.776,14,22.5,14z";
}

#plusIcon:pressed {

}

#settingsIcon:pressed {
    -fx-background-insets: 3, 3, 3, 3;
    -fx-border-color: #0b1d26;
}

#homeIcon:hover {
    -fx-border-color: white;
}

#homeIcon:pressed {
    -fx-background-insets: 0, 0, 0, 0;
    -fx-border-color: white;
}

#workoutBuddyHeader {
    -fx-border-color: #143749;
}

.button {
    -fx-background-radius: 0px;
    -fx-border-color: #143749;
}

.button:pressed {
    -fx-border-color: #0b1d26;
}

.button:focused {
    -fx-backgrou d-insets: 0, 0, 0, 0;
    -fx-background-border: transparent;
}

.buttonBar:focused {
    -fx-background-color: #c4c7ce;
}

.text-field {
    -fx-background-radius: 0px;
}

.dialog-background {
    -fx-background-color: #c4c7ce;
}

我需要做什么才能使“添加练习”对话框没有透明背景?

0 个答案:

没有答案