两个组件之间的JavaFX空白边距-如何解决?

时间:2018-11-11 14:16:00

标签: java maven intellij-idea javafx scenebuilder

我开始使用SceneBuilder构建一个新的JavaFX项目。将ListView设置为导航(蓝色背景)并在hbox内放置一个窗格(红色背景)后,我运行了该程序,并在listView和Hbox之间得到了一个空白。为什么在这里,我该如何解决?

那是我的FMXL代码:

   <BorderPane fx:id="borderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="1100.0" styleClass="parent" stylesheets="@application.css" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.ApplicationController">
   <bottom>
      <HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="30.0" prefWidth="1100.0" BorderPane.alignment="CENTER">
         <children>
            <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="30.0" prefWidth="200.0" style="-fx-background-color: #c30221;" />
         </children>
      </HBox>
   </bottom>
   <left>
      <ListView fx:id="lvNavigation" focusTraversable="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="670.0" prefWidth="200.0" stylesheets="@../../bin/application/application.css" BorderPane.alignment="CENTER" />
   </left>
</BorderPane>

这是我的样式表:

.parent{
    -fx-background-color: #ffffff;
    -fx-padding: 0;
    -fx-margin: 0;
}

.list-view{
    -fx-background-color: #0051a6;
}

.list-cell{
    -fx-background-color: #0051a6;
    -fx-cell-size: 75px;
    -fx-text-fill: white;
}

那是我的主要班级:

    BorderPane root = (BorderPane) FXMLLoader.load(getClass().getResource("/fxml/application.fxml"));
    Scene scene = new Scene(root);
    scene.getStylesheets().add(getClass().getResource("/css/stylesheet.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.initStyle(StageStyle.DECORATED);
    primaryStage.setResizable(false);
    primaryStage.setTitle("Sneak/One");
    primaryStage.show();

SceneBuilder-View: SceneBuilder

运行后: After running

0 个答案:

没有答案