public void menuSelected(MenuEvent ev) {
boolean firstMenuItem = true;
// Fill menu dynamically with a menu item for the frame of each application home
for (Home home : homeApplication.getHomes()) {
final JFrame applicationFrame = homeApplication.getHomeFrame(home);
JCheckBoxMenuItem windowMenuItem = new JCheckBoxMenuItem(
new AbstractAction(applicationFrame.getTitle()) {
public void actionPerformed(ActionEvent ev) {
applicationFrame.toFront();
}
});
if (frame == applicationFrame) {
windowMenuItem.setSelected(true);
}
if (firstMenuItem) {
windowMenu.addSeparator();
firstMenuItem = false;
}