Current location - Recipe Complete Network - Complete cookbook - JAVA, how to realize that after clicking different menu items, the panel displays different contents to realize different functions?
JAVA, how to realize that after clicking different menu items, the panel displays different contents to realize different functions?
You need to add a listener similar to ActionListener to each menu item to react to mouse actions. Please refer to the JAVA tutorial on GUI for details.

For example: j menuitem1.addactionlistener (project handler);

ItemHandler is a listener that I wrote myself.

It is best to make JMenuItem into an array, which can save code.