void (int days) { int selectedDayIndex = myDays.getSelectedIndex(); myDays.removeAllItems(); for (int i = 0; i < days; i++) myDays.addItem(String.valueOf(i + 1)); if (selectedDayIndex < myDays.getItemCount()) myDays.setSelectedIndex(selectedDayIndex); else myDays.setSelectedIndex(myDays.getItemCount() - 1); }