myComboBox.setCellFactory(
new Callback, ListCell>() {
@Override
public ListCell call(ListView param) {
// TODO Auto-generated method stub
final ListCell cell=new ListCell(){
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
this.setText(null);
this.setGraphic(null);
if (!empty) {
Button b=new Button("X");
this.setGraphic(b);
this.setText(item);
b.setOnMouseReleased(new EventHandler() {
@Override
public void handle(Event event) {
// TODO Auto-generated method stub
System.out.println(myComboBox.getItems().remove(item));
System.out.println("I:"+item);
}
});
}
}
};
return cell;
}
});