给出-fx-alignment的警告:LEFT说没有枚举常量javafx.geometry.Pos.LEFT

Riz*_*aky 5 css java javafx

我正在使用一个外部css文件调用mainBut.css来对齐JavaFX按钮的文本,

按钮代码:

<Button fx:id="hostelBut"
        layoutX="7.0"
        layoutY="100.0"
        onAction="#hostelAction"
        prefHeight="30.0"
        prefWidth="150.0"
        styleClass="mainBut"
        stylesheets="@../resources/css/mainBut.css"
        text="Hostel">
Run Code Online (Sandbox Code Playgroud)

mainBut.css文件

.mainBut {
    -fx-background-color: #fdfdfd;
    -fx-alignment: LEFT;
    -fx-border-color: #bdc3c7;
}
Run Code Online (Sandbox Code Playgroud)

当我编译此文件并通过NetBeans运行它时,我收到以下警告.

WARNING: Caught java.lang.IllegalArgumentException: No enum constant javafx.geometry.Pos.LEFT' while calculating value for '-fx-alignment' from rule '*.mainBut' in stylesheet jar:file...
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能解决这个警告?

Tun*_*aki 10

LEFT不是该-fx-alignment属性的有效值.有效值为:

[左上角| 顶级中心| 右上角| 中左| 中心| 中右下左下| 中心| 右下角| baseline-left | 基线中心| 基线权利]

这些值映射到Pos类中对应的枚举.

您可能需要center-left,它代表垂直和左侧水平定位在中心.