Since your Button is in an AnchorPane
and you have both the left and right anchors set, the width is going to be controlled by those anchors, not by the prefWidth
property. An AnchorPane
is probably not the best way to go if you want to be able to dynamically resize the control, but you can do
AnchorPane.setRightAnchor(url, AnchorPane.getRightAnchor(url)+110);