Program: 49908
Project: 49908
Buggy source:
private JButton createViewCompletedGamesButton(){
  JButton viewCompletedGameButton=new JButton(Messages.getString("String_Node_Str"));
  viewCompletedGameButton.setToolTipText(Messages.getString("String_Node_Str"));
  viewCompletedGameButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent event){
      try {
        String[] files=FileUtility.getCompletedGamesFileArray();
        if (files.length == 0) {
          JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
          return;
        }
        final JFrame poppedFrame=new JFrame(Messages.getString("String_Node_Str"));
        poppedFrame.setLayout(new GridBagLayout());
        poppedFrame.setSize(225,200);
        poppedFrame.setResizable(false);
        poppedFrame.setLocationRelativeTo(Driver.this);
        GridBagConstraints constraints=new GridBagConstraints();
        final JList completedGamesList=new JList(FileUtility.getCompletedGamesFileArray());
        final JScrollPane scrollPane=new JScrollPane(completedGamesList);
        scrollPane.setPreferredSize(new Dimension(200,200));
        completedGamesList.setSelectedIndex(0);
        JButton nextButton=new JButton(Messages.getString("String_Node_Str"));
        nextButton.addActionListener(new ActionListener(){
          @Override public void actionPerformed(          ActionEvent event){
            if (completedGamesList.getSelectedValue() == null) {
              JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
              return;
            }
            File file=FileUtility.getCompletedGamesFile(completedGamesList.getSelectedValue().toString());
            FileInputStream fileInputStream;
            ObjectInputStream objectInputStream;
            Game gameToView;
            if (completedGamesList.getSelectedValue().toString().endsWith("String_Node_Str")) {
              try {
                mOtherPanel=new PlayGamePanel(true,file);
              }
 catch (              Exception e) {
                JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
                return;
              }
            }
 else {
              try {
                fileInputStream=new FileInputStream(file);
                objectInputStream=new ObjectInputStream(fileInputStream);
                gameToView=(Game)objectInputStream.readObject();
                setPanel(new PlayGamePanel(gameToView,false));
                poppedFrame.dispose();
              }
 catch (              Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
              }
            }
            deactivateWindowListener();
            poppedFrame.dispose();
          }
        }
);
        JButton cancelButton=new JButton(Messages.getString("String_Node_Str"));
        GuiUtility.setupCancelButton(cancelButton,poppedFrame);
        JButton deleteButton=new JButton(Messages.getString("String_Node_Str"));
        deleteButton.addActionListener(new ActionListener(){
          @Override public void actionPerformed(          ActionEvent event){
            if (completedGamesList.getSelectedValue() != null) {
              boolean didDeleteCompletedGameSuccessfully=FileUtility.getCompletedGamesFile(completedGamesList.getSelectedValue().toString()).delete();
              if (!didDeleteCompletedGameSuccessfully) {
                JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
              }
 else {
                completedGamesList.removeAll();
                completedGamesList.setListData(FileUtility.getCompletedGamesFileArray());
                completedGamesList.setSelectedIndex(0);
                if (completedGamesList.getSelectedValue() == null) {
                  JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
                  poppedFrame.dispose();
                }
                scrollPane.getViewport().add(completedGamesList,null);
              }
            }
 else {
              JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
            }
          }
        }
);
        constraints.gridx=0;
        constraints.gridy=0;
        constraints.gridwidth=2;
        constraints.insets=new Insets(5,5,5,5);
        poppedFrame.add(scrollPane,constraints);
        constraints.gridx=0;
        constraints.gridy=1;
        poppedFrame.add(deleteButton,constraints);
        constraints.weighty=1.0;
        constraints.weightx=1.0;
        constraints.gridx=0;
        constraints.gridy=2;
        constraints.gridwidth=1;
        constraints.anchor=GridBagConstraints.EAST;
        poppedFrame.add(nextButton,constraints);
        constraints.gridx=1;
        constraints.gridy=2;
        constraints.anchor=GridBagConstraints.WEST;
        poppedFrame.add(cancelButton,constraints);
        poppedFrame.setVisible(true);
        poppedFrame.pack();
      }
 catch (      Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
      }
    }
  }
);
  return viewCompletedGameButton;
}

Fixed version (ground truth):
private JButton createViewCompletedGamesButton(){
  JButton viewCompletedGameButton=new JButton(Messages.getString("String_Node_Str"));
  viewCompletedGameButton.setToolTipText(Messages.getString("String_Node_Str"));
  try {
    viewCompletedGameButton.setIcon(GuiUtility.createImageIcon(30,30,FileUtility.getImagePath("String_Node_Str",true)));
  }
 catch (  IOException ae) {
    ae.printStackTrace();
  }
  viewCompletedGameButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent event){
      try {
        String[] files=FileUtility.getCompletedGamesFileArray();
        if (files.length == 0) {
          JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
          return;
        }
        final JFrame poppedFrame=new JFrame(Messages.getString("String_Node_Str"));
        poppedFrame.setLayout(new GridBagLayout());
        poppedFrame.setSize(225,200);
        poppedFrame.setResizable(false);
        poppedFrame.setLocationRelativeTo(Driver.this);
        GridBagConstraints constraints=new GridBagConstraints();
        final JList completedGamesList=new JList(FileUtility.getCompletedGamesFileArray());
        final JScrollPane scrollPane=new JScrollPane(completedGamesList);
        scrollPane.setPreferredSize(new Dimension(200,200));
        completedGamesList.setSelectedIndex(0);
        JButton nextButton=new JButton(Messages.getString("String_Node_Str"));
        nextButton.addActionListener(new ActionListener(){
          @Override public void actionPerformed(          ActionEvent event){
            if (completedGamesList.getSelectedValue() == null) {
              JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
              return;
            }
            File file=FileUtility.getCompletedGamesFile(completedGamesList.getSelectedValue().toString());
            FileInputStream fileInputStream;
            ObjectInputStream objectInputStream;
            Game gameToView;
            if (completedGamesList.getSelectedValue().toString().endsWith("String_Node_Str")) {
              try {
                mOtherPanel=new PlayGamePanel(true,file);
              }
 catch (              Exception e) {
                JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
                return;
              }
            }
 else {
              try {
                fileInputStream=new FileInputStream(file);
                objectInputStream=new ObjectInputStream(fileInputStream);
                gameToView=(Game)objectInputStream.readObject();
                setPanel(new PlayGamePanel(gameToView,false));
                poppedFrame.dispose();
              }
 catch (              Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
              }
            }
            deactivateWindowListener();
            poppedFrame.dispose();
          }
        }
);
        JButton cancelButton=new JButton(Messages.getString("String_Node_Str"));
        GuiUtility.setupCancelButton(cancelButton,poppedFrame);
        JButton deleteButton=new JButton(Messages.getString("String_Node_Str"));
        deleteButton.addActionListener(new ActionListener(){
          @Override public void actionPerformed(          ActionEvent event){
            if (completedGamesList.getSelectedValue() != null) {
              boolean didDeleteCompletedGameSuccessfully=FileUtility.getCompletedGamesFile(completedGamesList.getSelectedValue().toString()).delete();
              if (!didDeleteCompletedGameSuccessfully) {
                JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
              }
 else {
                completedGamesList.removeAll();
                completedGamesList.setListData(FileUtility.getCompletedGamesFileArray());
                completedGamesList.setSelectedIndex(0);
                if (completedGamesList.getSelectedValue() == null) {
                  JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
                  poppedFrame.dispose();
                }
                scrollPane.getViewport().add(completedGamesList,null);
              }
            }
 else {
              JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
            }
          }
        }
);
        constraints.gridx=0;
        constraints.gridy=0;
        constraints.gridwidth=2;
        constraints.insets=new Insets(5,5,5,5);
        poppedFrame.add(scrollPane,constraints);
        constraints.gridx=0;
        constraints.gridy=1;
        poppedFrame.add(deleteButton,constraints);
        constraints.weighty=1.0;
        constraints.weightx=1.0;
        constraints.gridx=0;
        constraints.gridy=2;
        constraints.gridwidth=1;
        constraints.anchor=GridBagConstraints.EAST;
        poppedFrame.add(nextButton,constraints);
        constraints.gridx=1;
        constraints.gridy=2;
        constraints.anchor=GridBagConstraints.WEST;
        poppedFrame.add(cancelButton,constraints);
        poppedFrame.setVisible(true);
        poppedFrame.pack();
      }
 catch (      Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(Driver.getInstance(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"),JOptionPane.PLAIN_MESSAGE);
      }
    }
  }
);
  return viewCompletedGameButton;
}