Reputation: 1
for example, I want to make 3 combo boxes 1st one called destination 2nd one called Take off airport 3rd one called Arrival airport then if user choose destination : France, Take off airport :Cairo international so i want to make the only available choice of arrival airport is Lyon-Saint-Exupery also if user choose destination : France, Take off airport : Hurghada international airport i want to make the only available choice of arrival airport is Orly international airport
Upvotes: 0
Views: 115
Reputation: 78
If I understood your question, then you want to if you select France
in a JComboBox Then Other Boxes will show the airports in France
? or only a single Airport?
Is the answer looking like this? Just Add an itemlistener
to the first combobox
and add the items to the other comboboxes
and make sure to remove all the items from the other two boxes while selecting from the first combobox
Box1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent arg0) {
if(Box1.getSelectedItem().equals("France")){
Box2.removeAllItems();
Box2.addItem("Cairo");
}
}
});
Upvotes: 2