Java Adding key and value to a JComboBox Part I

preview_player
Показать описание
Java Adding key and value to a JComboBox Part I

Adding items to a JComboBox

#JComboBox

===============================================

public class ComboItems {

private String key;
private String value;

 public ComboItems(String key, String value) {
}

@Override
public String toString() {
return key;
}

public String getKey() {
return key;
}

public String getValue() {
return value;
}
}

Add Items
DefaultComboBoxModel model = new DefaultComboBoxModel();



Get Item

PSC Study Materials and Previous Question Papers
Any doubts and help to type comments below
Рекомендации по теме
Комментарии
Автор

Thanks a lot, this video helped me very much, God bless you.

paullarrea
Автор

Excelente, tenia que implemenar un combobox desde una tabla de base de datos con (key, value).
saludos

ricardogarces
Автор

Thanks for the video! Do you have one where you see the opposite operation, ie where you set the value of the JComboBox set by an ID coming from a database? Thank you.

AntonioMonti
Автор

why do I only get the last value for each item

muhammadramdan