Purpose: JComboBox to list the ages that the user can select
I understand that I need an array of integers. What part of the Math functions in Java will allow me to do this easily? The list of numbers will be from 1 to 100 in sequential order.
I donβt quite understand why you need math functions.
This will work:
List<Integer> age = new ArrayList<Integer>(); for (int i = 1; i <= 100; ++i) { age.add(i); } JComboBox ageComboBox = new JComboBox(age.toArray());
You do not need math functions. Take a look at JComboBox in java docs and you will find the .addItem function. It can take a string (for example, "1") or a number (for example, a new integer (1)). Just go to the for loop and add the elements you need.
.addItem
I suspect JSpinner using SpinnerNumberModel will be the best component for choosing integer age or YOB. For more details, see How to use Spinners in the tutorial.
JSpinner
SpinnerNumberModel
maybe you look ComboBox / JTextField Autocomplete