【发布时间】:2021-05-13 11:22:51
【问题描述】:
如何将Label Label 1 定位在单元格的左上角?我尝试相应地设置标签的对齐方式,但这并没有成功。
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Tooltip?>
<?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?>
<GridPane hgap="14.0" vgap="7.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="400.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints />
<RowConstraints />
</rowConstraints>
<children>
<Label text="Label 1" />
<VBox spacing="4.0" GridPane.columnIndex="2">
<children>
<HBox spacing="4.0">
<children>
<TextField styleClass="" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip style="-fx-font-size: 100%;" text="Subject 1; Subject 2; Subject 3" />
</tooltip>
</TextField>
<Button mnemonicParsing="false" text="Add" />
</children>
</HBox>
<ScrollPane hbarPolicy="NEVER" maxHeight="-Infinity" prefHeight="61.0" />
</children>
</VBox>
<Label text="Label 2" GridPane.rowIndex="1" />
<CheckBox mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<HBox alignment="CENTER_LEFT" spacing="4.0" GridPane.columnIndex="2" GridPane.rowIndex="1">
<children>
<TextField HBox.hgrow="ALWAYS" />
<Hyperlink text="duplicate" />
</children>
</HBox>
</children>
</GridPane>
d
【问题讨论】: