I would like to ask a question about combobox as I mentioned a little bit in title. I want to make 2 comboboxes which one of them contains departure cities, the other one contains arrival cities.
For example:
We have got destinations as New York , Paris and Dubai. So when I choose New York in departure I don't want to see New York in other combo box (as arrival). How can I do these ?
JComboBox Departure = new JComboBox();
Departure.setBounds(31, 58, 28, 20);
contentPane.add(Departure);
JComboBox Arrival = new JComboBox();
Arrival.setBounds(114, 58, 28, 20);
contentPane.add(Arrival);`
you can use this
for(int i = 0; i < Departure.getItemCount(); i++){
if(Departure.getItemAt(i).equals(Departure.getSelectedItem())){
Arrival.removeItemAt(i):
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.