我是一名 Java 初学者,正在制作一个 GUI 程序,其中包含月份的下拉列表,例如
JComboBox month;
public static String[] monthname = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
month = new JComboBox(monthname);
我已将它添加到框架中并且它工作正常。我想为月份名称数组的每个索引分配数值。如果用户选择四月,我只想实现,如何针对四月分配值 4。