我正在构建一个javaFx应用程序,ui是在fxml文件中构建的,我在其中使用了一个锚定窗格,一个HBox然后是一个表,但是我的表第一行出现了一条奇怪的蓝线并且周围。 我也附了截图。 我的fxml文件是: -
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<AnchorPane fx:id="ap" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.Buildsapp.Main.BuildsController">
<children>
<HBox alignment="CENTER_LEFT" layoutX="6.0" layoutY="14.0" spacing="20.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="10.0" right="3.0" top="5.0" />
</padding>
</HBox>
<TableView fx:id="tableView" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="2.0" AnchorPane.rightAnchor="2.0" AnchorPane.topAnchor="70.0">
<columns>
<TableColumn fx:id="builds" prefWidth="482.0" text="Builds" />
<TableColumn fx:id="date" minWidth="0.0" prefWidth="500.0" text="Date" />
</columns>
</TableView>
<ComboBox fx:id="versionCombo" layoutX="2.0" layoutY="28.0" prefHeight="31.0" prefWidth="108.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Win" />
<String fx:value="Mac" />
</FXCollections>
</items>
<value>
<String fx:value="Mac" />
</value>
</ComboBox>
<ComboBox fx:id="verCombo" layoutX="127.0" layoutY="28.0" prefHeight="31.0" prefWidth="127.0" promptText="builds">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="builds" />
<String fx:value="builds2" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="versionNo" layoutX="265.0" layoutY="28.0" prefHeight="31.0" prefWidth="109.0" />
<ComboBox fx:id="locCombo" layoutX="391.0" layoutY="28.0" prefHeight="31.0" prefWidth="103.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="SJ" />
<String fx:value="MN" />
</FXCollections>
</items>
<value>
<String fx:value="SJ" />
</value>
</ComboBox>
<Button fx:id="downloadButton" layoutX="505.0" layoutY="28.0" minWidth="80.0" mnemonicParsing="false" text="Download" />
<Button fx:id="installButton" layoutX="614.0" layoutY="28.0" minWidth="80.0" mnemonicParsing="false" text="Install" />
<Button fx:id="locButton" layoutX="721.0" layoutY="28.0" mnemonicParsing="false" prefHeight="31.0" prefWidth="120.0" text="Open Folder" />
<Label layoutX="4.0" layoutY="4.0" prefHeight="21.0" prefWidth="88.0" text="Platform" />
<Label layoutX="127.0" layoutY="4.0" prefHeight="21.0" prefWidth="80.0" text="Product" />
<Label layoutX="269.0" layoutY="4.0" text="Version" />
<Label layoutX="391.0" layoutY="4.0" prefHeight="21.0" prefWidth="60.0" text="Server" />
</children>
</AnchorPane>
答案 0 :(得分:1)
您的表格是您布局中的第一个项目,并且具有焦点。这就是它突出的原因。此外,您的布局中有HBox
,但其中没有任何内容。通常,您应该使用自动处理布局的容器,而不是绝对定位节点。
这是您的场景的另一种布局,可以让您的生活更轻松。
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<AnchorPane fx:id="ap" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="840.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.Buildsapp.Main.BuildsController">
<children>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<HBox alignment="CENTER_LEFT" spacing="20.0" VBox.vgrow="NEVER">
<padding>
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0" />
</padding>
<children>
<GridPane hgap="10.0" vgap="3.0" HBox.hgrow="NEVER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="-Infinity" vgrow="SOMETIMES" />
<RowConstraints minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label prefHeight="21.0" prefWidth="88.0" text="Platform" />
<ComboBox fx:id="versionCombo" maxWidth="1.7976931348623157E308" minWidth="-Infinity" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Win" />
<String fx:value="Mac" />
</FXCollections>
</items>
<value>
<String fx:value="Mac" />
</value>
</ComboBox>
<Label prefHeight="21.0" prefWidth="80.0" text="Product" GridPane.columnIndex="1" />
<ComboBox fx:id="verCombo" maxWidth="1.7976931348623157E308" minWidth="-Infinity" promptText="builds" GridPane.columnIndex="1" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="builds" />
<String fx:value="builds2" />
</FXCollections>
</items>
</ComboBox>
<Label text="Version" GridPane.columnIndex="2" />
<ComboBox fx:id="versionNo" maxWidth="1.7976931348623157E308" minWidth="-Infinity" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Label prefHeight="21.0" prefWidth="60.0" text="Server" GridPane.columnIndex="3" />
<ComboBox fx:id="locCombo" maxWidth="1.7976931348623157E308" minWidth="-Infinity" GridPane.columnIndex="3" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="SJ" />
<String fx:value="MN" />
</FXCollections>
</items>
<value>
<String fx:value="SJ" />
</value>
</ComboBox>
<Button fx:id="downloadButton" maxWidth="1.7976931348623157E308" minWidth="-Infinity" mnemonicParsing="false" text="Download" GridPane.columnIndex="4" GridPane.rowIndex="1" />
<Button fx:id="installButton" maxWidth="1.7976931348623157E308" minWidth="-Infinity" mnemonicParsing="false" text="Install" GridPane.columnIndex="5" GridPane.rowIndex="1" />
<Button fx:id="locButton" minWidth="-Infinity" mnemonicParsing="false" text="Open Folder" GridPane.columnIndex="6" GridPane.rowIndex="1" />
</children>
</GridPane>
</children>
</HBox>
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="builds" prefWidth="482.0" text="Builds" />
<TableColumn fx:id="date" minWidth="0.0" prefWidth="500.0" text="Date" />
</columns>
</TableView>
</children>
</VBox>
</children>
</AnchorPane>