RIzan Zaky RIzan Zaky - 4 months ago 10
Java Question

Warning given for -fx-alignment: LEFT saying no enum constant javafx.geometry.Pos.LEFT

I'm using an external css file called

mainBut.css
to align the text of a JavaFX button,

Code for the button:

<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">


The
mainBut.css
file

.mainBut {
-fx-background-color: #fdfdfd;
-fx-alignment: LEFT;
-fx-border-color: #bdc3c7;
}


When I compile this file and run it via NetBeans, I get the following warning.

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...


What can I do to fix this warning?

Answer

LEFT is not a valid value for the -fx-alignment property. Valid values are:

[ top-left | top-center | top-right | center-left | center | center-right bottom-left | bottom-center | bottom-right | baseline-left | baseline-center | baseline-right ]

Those values are mapped to their corresponding enum in Pos class.

You probably want center-left instead, which represents positioning on the center vertically and on the left horizontally.

Comments