List of utility methods to do JComboBox Model
void | addItem(DefaultComboBoxModel model, String elem) add Item model.addElement(elem); |
void | addItems(DefaultComboBoxModel comboBox, Iterable items) add Items for (Object item : items) {
comboBox.addElement(item);
|
boolean | comboBoxContains(DefaultComboBoxModel model, Object obj) Checks to see if a JComboBox contains an object. for (int i = 0; i < model.getSize(); i++) { if (obj.equals(model.getElementAt(i))) { return true; return false; |
Vector | convertDefaultComboBoxModelToVector(DefaultComboBoxModel model) convert Default Combo Box Model To Vector Vector v = new Vector(); for (int i = 0; i < model.getSize(); i++) { v.add(model.getElementAt(i)); return v; |
ComboBoxModel | generateComboModel(Object[] values) generate Combo Model DefaultComboBoxModel model = new DefaultComboBoxModel(values); return model; |
DefaultComboBoxModel | generateInsertWhereComboBoxModel(String label) generate Insert Where Combo Box Model Vector<String> values = new Vector<String>(); values.add(label); values.add(ADD_AT_BEGINING); values.add(ADD_ABOVE_SELECTION); values.add(ADD_BELOW_SELECTION); values.add(ADD_AT_END); return new DefaultComboBoxModel(values); |
List | getComboModelList(ComboBoxModel> model) Return a List of Objects from a ComboBoxModel ArrayList<Object> list = new ArrayList<Object>(); for (int i = 0; i < model.getSize(); i++) { list.add(model.getElementAt(i)); return list; |
DefaultComboBoxModel | getNewDefaultComboBoxModel(ArrayList Creates a new Default Combo Box Model from the ArrayList if items DefaultComboBoxModel newModel = new DefaultComboBoxModel(); itemsToStream.stream().forEach((c) -> { newModel.addElement(c); }); return newModel; |
Object | getSelectedItemfromModel(Object combo) get Selected Itemfrom Model return ((ComboBoxModel) combo).getSelectedItem();
|
boolean | hasDataChanged(List Checks whether the data has changed and the model needs updating. boolean result; int i; Set<String> setDatasets; Set<String> setModel; setDatasets = new HashSet<>(newDatasets); setModel = new HashSet<>(); for (i = 0; i < currentModel.getSize(); i++) setModel.add(currentModel.getElementAt(i)); ... |