如何在javafx中去掉空间
我正在使用JavaFX SceneBuilder创建FXML。我的窗口只是一个边框窗格:宽度800,高度625。顶部是一个菜单栏:宽度使用大小,高度25。中间是一个锚平面:宽度800,高度600。在它里面,我使用宽度为800,高度为600的ImageView作为背景图像 它完全适用于SceneBuilder,但当我作为Java应用程序运行时,在右边和底部都有空白,如下所示: 请帮助删除它,对不起,我是JavaFx的新手 更新:我已经将它分为2个布局,然后是RootLayout setCenter main布局,但它不起作用 RootLayout.fxml:如何在javafx中去掉空间,java,javafx,Java,Javafx,我正在使用JavaFX SceneBuilder创建FXML。我的窗口只是一个边框窗格:宽度800,高度625。顶部是一个菜单栏:宽度使用大小,高度25。中间是一个锚平面:宽度800,高度600。在它里面,我使用宽度为800,高度为600的ImageView作为背景图像 它完全适用于SceneBuilder,但当我作为Java应用程序运行时,在右边和底部都有空白,如下所示: 请帮助删除它,对不起,我是JavaFx的新手 更新:我已经将它分为2个布局,然后是RootLayout setCenter
<BorderPane prefHeight="625.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chotoxautinh.controller.RootController">
<top>
<MenuBar prefHeight="25.0" prefWidth="800.0" BorderPane.alignment="CENTER">
<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>
</top>
</BorderPane>
<AnchorPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chotoxautinh.controller.MainController">
<children>
<ImageView focusTraversable="true" layoutX="735.0" layoutY="521.0" pickOnBounds="true" preserveRatio="true" styleClass="ruleButton" AnchorPane.bottomAnchor="25.0" AnchorPane.rightAnchor="23.0">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
<image>
<Image url="@../../../../resources/images/rule-button.png" />
</image>
</ImageView>
<ImageView fitHeight="600.0" fitWidth="800.0" pickOnBounds="true">
<image>
<Image url="@../../../../resources/images/background.png" />
</image>
</ImageView>
<VBox alignment="CENTER" layoutX="510.0" layoutY="172.0" prefHeight="330.0" prefWidth="290.0" spacing="29.0" styleClass="mainButtonLayout">
<children>
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" opacity="0.7" prefHeight="47.0" prefWidth="220.0" text="CLASSIC MODE">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" opacity="0.7" prefHeight="47.0" prefWidth="220.0" text="ENDLESS MODE">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" opacity="0.7" prefHeight="47.0" prefWidth="220.0" text="MULTIPLAYER">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Label style="-fx-text-fill: #333;" text="Designed by ChoToXauTinh - ©2015 Paduvi.Ltd" translateY="33.0" />
</children>
</VBox>
</children>
</AnchorPane>
MainLayout.fxml:
<BorderPane prefHeight="625.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chotoxautinh.controller.RootController">
<top>
<MenuBar prefHeight="25.0" prefWidth="800.0" BorderPane.alignment="CENTER">
<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>
</top>
</BorderPane>
<AnchorPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chotoxautinh.controller.MainController">
<children>
<ImageView focusTraversable="true" layoutX="735.0" layoutY="521.0" pickOnBounds="true" preserveRatio="true" styleClass="ruleButton" AnchorPane.bottomAnchor="25.0" AnchorPane.rightAnchor="23.0">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
<image>
<Image url="@../../../../resources/images/rule-button.png" />
</image>
</ImageView>
<ImageView fitHeight="600.0" fitWidth="800.0" pickOnBounds="true">
<image>
<Image url="@../../../../resources/images/background.png" />
</image>
</ImageView>
<VBox alignment="CENTER" layoutX="510.0" layoutY="172.0" prefHeight="330.0" prefWidth="290.0" spacing="29.0" styleClass="mainButtonLayout">
<children>
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" opacity="0.7" prefHeight="47.0" prefWidth="220.0" text="CLASSIC MODE">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" opacity="0.7" prefHeight="47.0" prefWidth="220.0" text="ENDLESS MODE">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" opacity="0.7" prefHeight="47.0" prefWidth="220.0" text="MULTIPLAYER">
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Label style="-fx-text-fill: #333;" text="Designed by ChoToXauTinh - ©2015 Paduvi.Ltd" translateY="33.0" />
</children>
</VBox>
</children>
</AnchorPane>
如果没有任何代码,很难说哪个组件负责空间。您可以将FXML添加到您的问题中吗?您可以使用来检查场景。正如ItachiUchiha提到的,我们只能在没有代码的情况下猜测。对不起,伙计们,我添加了fxml代码above@Việ德克萨斯州ấuTính样式类ruleButton中有什么?@ItachiUchiha-fx focus traversable:true;