Program: 45231
Project: 45231
Buggy source:
public void menuSelected(MenuEvent e){
  Object source=e.getSource();
  if (source == viewMenu) {
switch (mainFrame.getActiveTable().getSortByCriteria()) {
case Columns.EXTENSION:
      sortByExtensionItem.setSelected(true);
    break;
case Columns.NAME:
  sortByNameItem.setSelected(true);
break;
case Columns.SIZE:
sortBySizeItem.setSelected(true);
break;
case Columns.DATE:
sortByDateItem.setSelected(true);
break;
}
}
 else if (source == columnsMenu) {
FileTable activeTable=mainFrame.getActiveTable();
toggleExtensionColumnItem.setSelected(activeTable.isColumnVisible(Columns.EXTENSION));
toggleSizeColumnItem.setSelected(activeTable.isColumnVisible(Columns.SIZE));
toggleDateColumnItem.setSelected(activeTable.isColumnVisible(Columns.DATE));
togglePermissionsColumnItem.setSelected(activeTable.isColumnVisible(Columns.PERMISSIONS));
}
 else if (source == goMenu) {
for (int i=goMenu.getItemCount(); i > rootFoldersOffset; i--) goMenu.remove(rootFoldersOffset);
AbstractFile rootFolders[]=RootFolders.getRootFolders();
int nbFolders=rootFolders.length;
for (int i=0; i < nbFolders; i++) goMenu.add(new OpenLocationAction(mainFrame,rootFolders[i]));
}
 else if (source == bookmarksMenu) {
for (int i=bookmarksMenu.getItemCount(); i > bookmarksOffset; i--) bookmarksMenu.remove(bookmarksOffset);
Vector bookmarks=BookmarkManager.getBookmarks();
int nbBookmarks=bookmarks.size();
if (nbBookmarks > 0) {
Bookmark b;
for (int i=0; i < nbBookmarks; i++) MenuToolkit.addMenuItem(bookmarksMenu,new OpenLocationAction(mainFrame,(Bookmark)bookmarks.elementAt(i)),null);
}
 else {
JMenuItem noBookmarkItem=MenuToolkit.addMenuItem(bookmarksMenu,Translator.get("String_Node_Str"),null,null,null);
noBookmarkItem.setEnabled(false);
}
}
 else if (source == windowMenu) {
if (mainFrame.getSplitPaneOrientation()) splitVerticallyItem.setSelected(true);
 else splitHorizontallyItem.setSelected(true);
for (int i=windowMenu.getItemCount(); i > windowOffset; i--) windowMenu.remove(windowOffset);
windowMenuFrames=new WeakHashMap();
java.util.Vector mainFrames=WindowManager.getMainFrames();
MainFrame mainFrame;
JCheckBoxMenuItem checkBoxMenuItem;
int nbFrames=mainFrames.size();
for (int i=0; i < nbFrames; i++) {
mainFrame=(MainFrame)mainFrames.elementAt(i);
checkBoxMenuItem=new JCheckBoxMenuItem();
if (i < 10) checkBoxMenuItem.setAction(ActionManager.getActionInstance(RECALL_WINDOW_ACTIONS[i],this.mainFrame));
 else {
checkBoxMenuItem.addActionListener(this);
windowMenuFrames.put(checkBoxMenuItem,mainFrame);
}
checkBoxMenuItem.setText((i + 1) + "String_Node_Str" + mainFrame.getActiveTable().getCurrentFolder().getAbsolutePath());
checkBoxMenuItem.setSelected(mainFrame == this.mainFrame);
windowMenu.add(checkBoxMenuItem);
}
Frame frames[]=Frame.getFrames();
nbFrames=frames.length;
Frame frame;
JMenuItem menuItem;
boolean firstFrame=true;
for (int i=0; i < nbFrames; i++) {
frame=frames[i];
if (frame.isShowing() && ((frame instanceof ViewerFrame) || (frame instanceof EditorFrame))) {
if (firstFrame) {
windowMenu.add(new JSeparator());
firstFrame=false;
}
menuItem=new JMenuItem(frame.getTitle());
menuItem.addActionListener(this);
windowMenu.add(menuItem);
windowMenuFrames.put(menuItem,frame);
}
}
}
 else if (source == themesMenu) {
themesMenu.removeAll();
ButtonGroup buttonGroup=new ButtonGroup();
Iterator themes=ThemeManager.availableThemes();
Theme theme;
JCheckBoxMenuItem item;
while (themes.hasNext()) {
theme=(Theme)themes.next();
item=new JCheckBoxMenuItem(new ChangeCurrentThemeAction(theme));
buttonGroup.add(item);
if (ThemeManager.isCurrentTheme(theme)) item.setSelected(true);
themesMenu.add(item);
}
}
}

Fixed version (ground truth):
public void menuSelected(MenuEvent e){
  Object source=e.getSource();
  if (source == viewMenu) {
switch (mainFrame.getActiveTable().getSortByCriteria()) {
case Columns.EXTENSION:
      sortByExtensionItem.setSelected(true);
    break;
case Columns.NAME:
  sortByNameItem.setSelected(true);
break;
case Columns.SIZE:
sortBySizeItem.setSelected(true);
break;
case Columns.DATE:
sortByDateItem.setSelected(true);
break;
}
}
 else if (source == columnsMenu) {
FileTable activeTable=mainFrame.getActiveTable();
toggleExtensionColumnItem.setSelected(activeTable.isColumnVisible(Columns.EXTENSION));
toggleSizeColumnItem.setSelected(activeTable.isColumnVisible(Columns.SIZE));
toggleDateColumnItem.setSelected(activeTable.isColumnVisible(Columns.DATE));
togglePermissionsColumnItem.setSelected(activeTable.isColumnVisible(Columns.PERMISSIONS));
}
 else if (source == goMenu) {
for (int i=goMenu.getItemCount(); i > rootFoldersOffset; i--) goMenu.remove(rootFoldersOffset);
AbstractFile rootFolders[]=RootFolders.getRootFolders();
int nbFolders=rootFolders.length;
for (int i=0; i < nbFolders; i++) goMenu.add(new OpenLocationAction(mainFrame,new Hashtable(),rootFolders[i]));
}
 else if (source == bookmarksMenu) {
for (int i=bookmarksMenu.getItemCount(); i > bookmarksOffset; i--) bookmarksMenu.remove(bookmarksOffset);
Vector bookmarks=BookmarkManager.getBookmarks();
int nbBookmarks=bookmarks.size();
if (nbBookmarks > 0) {
Bookmark b;
for (int i=0; i < nbBookmarks; i++) MenuToolkit.addMenuItem(bookmarksMenu,new OpenLocationAction(mainFrame,new Hashtable(),(Bookmark)bookmarks.elementAt(i)),null);
}
 else {
JMenuItem noBookmarkItem=MenuToolkit.addMenuItem(bookmarksMenu,Translator.get("String_Node_Str"),null,null,null);
noBookmarkItem.setEnabled(false);
}
}
 else if (source == windowMenu) {
if (mainFrame.getSplitPaneOrientation()) splitVerticallyItem.setSelected(true);
 else splitHorizontallyItem.setSelected(true);
for (int i=windowMenu.getItemCount(); i > windowOffset; i--) windowMenu.remove(windowOffset);
windowMenuFrames=new WeakHashMap();
java.util.Vector mainFrames=WindowManager.getMainFrames();
MainFrame mainFrame;
JCheckBoxMenuItem checkBoxMenuItem;
int nbFrames=mainFrames.size();
for (int i=0; i < nbFrames; i++) {
mainFrame=(MainFrame)mainFrames.elementAt(i);
checkBoxMenuItem=new JCheckBoxMenuItem();
MucoAction recallWindowAction;
if (i < 10) {
recallWindowAction=ActionManager.getActionInstance(RECALL_WINDOW_ACTIONS[i],this.mainFrame);
}
 else {
Hashtable actionProps=new Hashtable();
actionProps.put(RecallWindowAction.WINDOW_NUMBER_PROPERTY_KEY,"String_Node_Str" + (i + 1));
recallWindowAction=ActionManager.getActionInstance(new ActionDescriptor(RecallWindowAction.class,actionProps),this.mainFrame);
}
checkBoxMenuItem.setAction(recallWindowAction);
checkBoxMenuItem.setText((i + 1) + "String_Node_Str" + mainFrame.getActiveTable().getCurrentFolder().getAbsolutePath());
checkBoxMenuItem.setToolTipText(recallWindowAction.getLabel());
checkBoxMenuItem.setSelected(mainFrame == this.mainFrame);
windowMenu.add(checkBoxMenuItem);
}
Frame frames[]=Frame.getFrames();
nbFrames=frames.length;
Frame frame;
JMenuItem menuItem;
boolean firstFrame=true;
for (int i=0; i < nbFrames; i++) {
frame=frames[i];
if (frame.isShowing() && ((frame instanceof ViewerFrame) || (frame instanceof EditorFrame))) {
if (firstFrame) {
windowMenu.add(new JSeparator());
firstFrame=false;
}
menuItem=new JMenuItem(frame.getTitle());
menuItem.addActionListener(this);
windowMenu.add(menuItem);
windowMenuFrames.put(menuItem,frame);
}
}
}
 else if (source == themesMenu) {
themesMenu.removeAll();
ButtonGroup buttonGroup=new ButtonGroup();
Iterator themes=ThemeManager.availableThemes();
Theme theme;
JCheckBoxMenuItem item;
while (themes.hasNext()) {
theme=(Theme)themes.next();
item=new JCheckBoxMenuItem(new ChangeCurrentThemeAction(theme));
buttonGroup.add(item);
if (ThemeManager.isCurrentTheme(theme)) item.setSelected(true);
themesMenu.add(item);
}
}
}