Question

In swing, how do i show a menu depending on what was selected from another menu.

For example: Select Country drop down. This is followed by a State drop down, followed by city.

When a particular Country is selected, then show the states for that country. Also, when a state is selected, show the cities in the state.

Was it helpful?

Solution

A JMenu can contain JMenuItem & JMenu instances. You might have it so that the main menu contains menus for countries. Each country menu has menus for states, then each state has menu items for city.

OTOH a nicer user experience would be provided by 3 JComboBox instances. The first is for the country, the 2nd and third are populated as needed (on demand).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top