Is it possible to populate a JComboBox with an int[]? I am writing a code that will use a JComboBox populated with years (in integers).
The code I have written is this:
JCombobox is generic, but Java generics don't support primitive type (and int is a primitive type).
JCombobox
int
So use an Integer array instead :
Integer
Integer[] birthYear = new Integer[currentYear]; //currentYear is an int variable int inc=1; for(int i=0;i birthYearBox = new JComboBox<>(birthYear);