JComboBox中列出的年龄 [英] JComboBox to list age

查看:89
本文介绍了JComboBox中列出的年龄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用途:JComboBox中列出下来的年龄,用户可以选择

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

我意识到我需要一个整型数组。哪一部分在Java中的数学函数可以让我轻松地做到这一点?号码列表将会从1-100顺序。

I realize that I need an array of integers. What part of the Math functions in Java will allow me to easily do that? The list of numbers will be from 1-100 in sequential order.

推荐答案

我不明白为什么你需要的数学函数。

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

这将工作:

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

这篇关于JComboBox中列出的年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆