I'm using a JFoenix library and I have a problem with ComboBox.
When I want to setPromtText and setButtonCell - the text duplicates. I want to change the size of font on ButtonCell.
Here is my code:
@FXML
private JFXComboBox versionList;
@Override
public void initialize(URL location, ResourceBundle resources) {
versionList.setPromptText("<");
versionList.setButtonCell(new ListCell<String>() {
@Override
protected void updateItem(String version, boolean empty) {
if (empty) {
setText(null);
} else {
setText(version);
setFont(Font.font(15));
}
}
});
}
And as the result I get this:
Or if promt text "Select":
What I'm doing wrong? Thanks in advance.
You have omitted to call the superclass implementation of
updateItem(...)
in your overriddenupdateItem(...)
method. According to the documentation this will prevent theitem
andempty
properties from being set; so I suspect that what is happening is that the cell still hasempty==true
, and consequently draws the prompt text when it shouldn't.The correct implementation should be