Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

java - JComboBox to list age

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 easily do that? The list of numbers will be from 1-100 in sequential order.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

This would work:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...