Can a Jcombobox hold an int? because i tried this and got an error.
int[] timeSched = new int[] {200,300,400,500}; JComboBox Jcombo1 = new JComboBox(timeSched);
Can a Jcombobox hold an int? because i tried this and got an error.
int[] timeSched = new int[] {200,300,400,500}; JComboBox Jcombo1 = new JComboBox(timeSched);
int[]
is not the same as Object[]
.
Instead of int[]
you can use Integer[]
which is a wrapper class for the primitive int
type, something like...
Integer[] timeSched = new Integer[] {200,300,400,500};
This allows the value to be passed to the JComboBox
's constructor which is expecting a generic array of Object
s.
Remember, generics in Java don't support primitives as there base class it defined off Object
and primitives are a special (non-object) type in Java