小编BCS*_*are的帖子

Populate a JComboBox with an int[]

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:

int[] birthYear = new int[currentYear]; //currentYear is an int variable
int inc=1;
for(int i=0;i<currentYear;i++)
{
    birthYear[i]= inc;
    inc++;
}

birthYearBox = new JComboBox(birthYear); //this is the line in which the error occurs
Run Code Online (Sandbox Code Playgroud)

I want these to integers in the ComboBox so that I can subtract from them. Do …

java arrays int swing jcombobox

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×1

int ×1

java ×1

jcombobox ×1

swing ×1