JComboBox to list age

后端 未结 4 1143
旧时难觅i
旧时难觅i 2020-12-07 05:12

Purpose: JComboBox to list down ages that a user can select

I realize that I need an array of integers. What part of the Math functions in Java will allow me to easi

4条回答
  •  心在旅途
    2020-12-07 06:14

    I don't quite understand why you need the Math functions.

    This would work:

    List age = new ArrayList();
    for (int i = 1; i <= 100; ++i) {
        age.add(i);
    }
    JComboBox ageComboBox = new JComboBox(age.toArray());
    

提交回复
热议问题