Use jComboBox1.getSelectedObjects()
instead if you want an array.
Though not necessary for String, you may want to call .toString()
on the returned Object when this line executes, just in case you happen to be storing Objects that are not String.
//error checking to println
System.out.println(jComboBox1.getSelectedItem() + " ");
Note that the .getSelectedObjects()
method wouldn't be the preferred one to use, as it's still only returning a single element in an Object[] array. If you need an array, it would be easier just to use .getSelectedItem()
and store the result in an array after the fact.
*Edited to reflect comment feedback.