So I have a JMenu with a few submenus inside. The names of those menus are set by getting the name of a 1 of 4 players. I added a MenuListener to the JMenu to update those names using
menu.setName(player.getName());
However, the name is changing but the update is not displaying in the menu. How do I get the menu to update it's display?
editMenu.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) {
updateMenu();
}
public void menuDeselected(MenuEvent e) {
}
public void menuCanceled(MenuEvent e) {
}
});
and updateMenu method:
public void updateMenu()
{
partOneMenu.setName(Participant1.getName());
partTwoMenu.setName(Participant2.getName());
partThreeMenu.setName(Participant3.getName());
partFourMenu.setName(Participant4.getName());
partOneMenu.revalidate();
partTwoMenu.revalidate();
partThreeMenu.revalidate();
partFourMenu.revalidate();
System.out.println(partOneMenu.getName());
}
The print statement is showing that the name has changed.