Combobox default value with objects?

Hello! im trying to set a default value on a combo box of objects, here is the code:

combo.setItems(at/*This is the array list of objects*/);
			combo.setItemLabelGenerator(Object::getName);
				combo.setValue(at.get(1));

Any idea? thank you!

Hi Mike,

You should set the ItemLabelGenerator before setting items, so try this:

combo.setItemLabelGenerator(Object::getName);
combo.setItems(at/*This is the array list of objects*/);
combo.setValue(at.get(1));

Martin Israelsen:
Hi Mike,

You should set the ItemLabelGenerator before setting items, so try this:

combo.setItemLabelGenerator(Object::getName);
combo.setItems(at/*This is the array list of objects*/);
combo.setValue(at.get(1));

Oh! that worked, thank you!