我似乎无法删除此GridPane的左右边框。见下图。
我的FXML文件是
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" style="-fx-box-border: transparent;" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8">
<padding>
<javafx.geometry.Insets top="0" right="0" left="0" bottom="0"/>
</padding>
<columnConstraints>
<ColumnConstraints percentWidth="33.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="33.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="33.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" percentHeight="33.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" percentHeight="33.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<StackPane prefHeight="150.0" prefWidth="200.0" style="-fx-background-color: red;" />
<StackPane prefHeight="150.0" prefWidth="200.0" style="-fx-background-color: red;" GridPane.columnIndex="2" GridPane.rowIndex="1" />
</children>
</GridPane>
正如你所看到的,我已经尝试将insets设置为0,并使边框透明但不起作用。
答案 0 :(得分:0)
您的问题很简单 - 您的列设置了percentWidth
,但总百分比加起来高达99%,而不是100%。要么将所有百分比改为33.33 ......,要么将其中一个改为34%,而另外两个则保持33%。