Taking the erhun sample linked in his comment as a starting point, define the ComboBox in fxml, as shown below, so that the list items include graphics shortcuts (these are your “badges”).
<ComboBox fx:id="fruitCombo" layoutX="15.0" layoutY="33.0" prefWidth="90.0" promptText="choose"> <items> <FXCollections fx:factory="observableArrayList"> <Label text="Apple"> <graphic> <StackPane prefWidth="50"> <ImageView fitHeight="32" preserveRatio="true"> <image> <Image url="http://uhallnyu.files.wordpress.com/2011/11/green-apple.jpg" preserveRatio="false" smooth="false" /> </image> </ImageView> </StackPane> </graphic> </Label> <Label text="Pear"> <graphic> <StackPane prefWidth="50"> <ImageView fitHeight="32" preserveRatio="true"> <image> <Image url="http://smoothiejuicerecipes.com/pear.jpg" preserveRatio="false" smooth="false" /> </image> </ImageView> </StackPane> </graphic> </Label> <Label text="Orange"> <graphic> <StackPane prefWidth="50"> <ImageView fitHeight="32" preserveRatio="true"> <image> <Image url="http://iicom.com/cnwk.1d/i/tim/2011/03/10/orange_iStock_000001331357X_540x405.jpg" preserveRatio="false" smooth="false" /> </image> </ImageView> </StackPane> </graphic> </Label> </FXCollections> </items> </ComboBox>
And in the FruitComboController initialization method, set a custom cell for the button (the simple cell below just takes the text of the done element, but you can also include graphics if you want):
ListCell<Label> buttonCell = new ListCell<Label>() { @Override protected void updateItem(Label item, boolean isEmpty) { super.updateItem(item, isEmpty); setText(item == null ? "" : item.getText()); } }; fruitCombo.setButtonCell(buttonCell);
The above is just one way to do this. Alternatively (and perhaps preferably) you can define a factory cell for your ComboBox , as Sebastian points out in his answer.
The yield of the modified sample:

source share