I need to create a combo box that can be modified by the user on the fly. I was able to do this in the android environment (Swing ComboBoxes seem to be the same as Android spinners) like this:
final Spinner spinner = (Spinner) findViewById(R.id.spinnerI);
String[] strings = configuration.getNames();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, strings);
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
How can I do something similar using Java Swing? Should even use the ComboBox in the Swing Palette? When I do a
jComboBoxImei.setModel(new javax.swing.MutableComboBoxModel()
after initComponents()
, JavaBeans wants me to implement all abstract methods (addElement(), removeElement(),
...). What is the simplest way to implement a dynamic ComboBox using Java and/or Swing?