I am seeing some odd behavior, where the preferred width of a javafx.scene.control.TextField isn't being computed correctly after calling setPrefColumnCount. My specific use case is for a javafx.scene.control.Spinner control. My code is as follows:
@FXML
private Spinner<Integer> mySpinner;
@Override
public void initialize(URL location, ResourceBundle resources) {
mySpinner.getEditor().setPrefColumnCount(3);
}
After executing the above, I get a spinner that is barely large enough for a single character (the spinner value is pictured at 999):
Does anyone know the correct way to set the width of a TextField based on the number of digits I want to be able to display? I am using JRE 8u77 on Windows 7 Enterprise SP1 x64, in case it matters.
EDIT
I have realized that part of the problem is that even if I measure the text via the instructions here, I still don't know what to set Spinner.prefWidth to. In addition, it appears that setting the prefWidth on the underlying TextField editor is no different than setting it on the Spinner object. Is there some way to get the TextField.padding property (returns 0 within the initialize method, even though it is eventually set to 7 on each side)? How about a way to query the width of the up/down arrows? If I could somehow compute/query these values, then I could use the measure text technique. Without that information, however, I can't figure out how to go about it.
