Program: 24474
Project: 24474
Buggy source:
public PalettePanel(INotationSubsystem notationSubsystem,final IViewBehaviourController editBehaviourController){
  final ButtonGroup paletteGroup=new ButtonGroup();
  JPanel selectionButtonPanel=new JPanel();
  selectionButtonPanel.setLayout(new BoxLayout(selectionButtonPanel,BoxLayout.PAGE_AXIS));
  final JButton selectionButton=new JButton("String_Node_Str");
  ImageIcon selectionIcon=createImageIcon("String_Node_Str");
  selectionButton.setIcon(selectionIcon);
  paletteGroup.add(selectionButton);
  selectionButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      editBehaviourController.setSelectionMode();
      paletteGroup.setSelected(selectionButton.getModel(),true);
    }
  }
);
  selectionButtonPanel.add(selectionButton);
  this.add(selectionButtonPanel);
  JPanel shapeButtonPanel=new JPanel();
  this.palettePane=new JScrollPane(shapeButtonPanel);
  this.palettePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  shapeButtonPanel.setLayout(new BoxLayout(shapeButtonPanel,BoxLayout.PAGE_AXIS));
  ShapeIconGenerator iconGenerator=new ShapeIconGenerator();
  iconGenerator.setBounds(new Envelope(0,0,16,16));
  Iterator<IShapeObjectType> shapeTypeIterator=notationSubsystem.getSyntaxService().shapeTypeIterator();
  while (shapeTypeIterator.hasNext()) {
    final IShapeObjectType shapeType=shapeTypeIterator.next();
    iconGenerator.setObjectType(shapeType);
    iconGenerator.generateImage();
    iconGenerator.generateIcon();
    final JButton shapeButton=new JButton(iconGenerator.getIcon());
    shapeButton.setText(shapeType.getName());
    shapeButton.setToolTipText(shapeType.getDescription());
    shapeButtonPanel.add(shapeButton);
    paletteGroup.add(shapeButton);
    shapeButton.addActionListener(new ActionListener(){
      @Override public void actionPerformed(      ActionEvent e){
        editBehaviourController.setShapeCreationMode(shapeType);
        paletteGroup.setSelected(shapeButton.getModel(),true);
      }
    }
);
  }
  JPanel linkButtonPanel=new JPanel();
  linkButtonPanel.setLayout(new BoxLayout(linkButtonPanel,BoxLayout.PAGE_AXIS));
  this.linkScrollPanel=new JScrollPane(linkButtonPanel);
  this.linkScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  LinkIconGenerator linkIconGenerator=new LinkIconGenerator();
  Iterator<ILinkObjectType> linkTypeIterator=notationSubsystem.getSyntaxService().linkTypeIterator();
  linkIconGenerator.setBounds(new Envelope(0.0,0.0,64.0,16.0));
  while (linkTypeIterator.hasNext()) {
    final ILinkObjectType linkType=linkTypeIterator.next();
    linkIconGenerator.setObjectType(linkType);
    linkIconGenerator.generateImage();
    linkIconGenerator.generateIcon();
    final JButton linkButton=new JButton(linkIconGenerator.getIcon());
    linkButton.setText(linkType.getName());
    linkButton.setToolTipText(linkType.getDescription());
    linkButtonPanel.add(linkButton);
    linkButton.addActionListener(new ActionListener(){
      @Override public void actionPerformed(      ActionEvent e){
        editBehaviourController.setLinkCreationMode(linkType);
        paletteGroup.setSelected(linkButton.getModel(),true);
      }
    }
);
  }
  this.setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
  this.splitPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT,this.palettePane,this.linkScrollPanel);
  this.splitPane.setOneTouchExpandable(true);
  this.splitPane.setDividerLocation(250);
  this.add(this.splitPane);
  paletteGroup.setSelected(selectionButton.getModel(),true);
  editBehaviourController.addViewBehaviourModeChangeListener(new IViewBehaviourModeChangeListener(){
    @Override public void viewModeChange(    IViewBehaviourModeChangeEvent e){
      if (e.getNewModeType().equals(ModeType.SELECTION)) {
        paletteGroup.setSelected(selectionButton.getModel(),true);
      }
    }
  }
);
}

Fixed version (ground truth):
public PalettePanel(INotationSubsystem notationSubsystem,final IViewBehaviourController editBehaviourController){
  final ButtonGroup paletteGroup=new ButtonGroup();
  JPanel selectionButtonPanel=new JPanel();
  selectionButtonPanel.setLayout(new BoxLayout(selectionButtonPanel,BoxLayout.PAGE_AXIS));
  final JButton selectionButton=new JButton("String_Node_Str");
  ImageIcon selectionIcon=createImageIcon("String_Node_Str");
  selectionButton.setIcon(selectionIcon);
  paletteGroup.add(selectionButton);
  selectionButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      editBehaviourController.setSelectionMode();
      paletteGroup.setSelected(selectionButton.getModel(),true);
    }
  }
);
  selectionButtonPanel.add(selectionButton);
  this.add(selectionButtonPanel);
  JPanel shapeButtonPanel=new JPanel();
  this.palettePane=new JScrollPane(shapeButtonPanel);
  this.palettePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  shapeButtonPanel.setLayout(new BoxLayout(shapeButtonPanel,BoxLayout.PAGE_AXIS));
  ShapeIconGenerator iconGenerator=new ShapeIconGenerator();
  iconGenerator.setBounds(new Envelope(0,0,16,16));
  Iterator<IShapeObjectType> shapeTypeIterator=notationSubsystem.getSyntaxService().shapeTypeIterator();
  while (shapeTypeIterator.hasNext()) {
    final IShapeObjectType shapeType=shapeTypeIterator.next();
    iconGenerator.setObjectType(shapeType);
    iconGenerator.generateImage();
    iconGenerator.generateIcon();
    final JButton shapeButton=new JButton(iconGenerator.getIcon());
    shapeButton.setText(shapeType.getName());
    shapeButton.setToolTipText(shapeType.getDescription());
    shapeButtonPanel.add(shapeButton);
    paletteGroup.add(shapeButton);
    shapeButton.addActionListener(new ActionListener(){
      @Override public void actionPerformed(      ActionEvent e){
        editBehaviourController.setShapeCreationMode(shapeType);
        paletteGroup.setSelected(shapeButton.getModel(),true);
      }
    }
);
  }
  JPanel linkButtonPanel=new JPanel();
  linkButtonPanel.setLayout(new BoxLayout(linkButtonPanel,BoxLayout.PAGE_AXIS));
  this.linkScrollPanel=new JScrollPane(linkButtonPanel);
  this.linkScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  LinkIconGenerator linkIconGenerator=new LinkIconGenerator();
  Iterator<ILinkObjectType> linkTypeIterator=notationSubsystem.getSyntaxService().linkTypeIterator();
  linkIconGenerator.setBounds(new Envelope(0.0,0.0,64.0,16.0));
  while (linkTypeIterator.hasNext()) {
    final ILinkObjectType linkType=linkTypeIterator.next();
    linkIconGenerator.setObjectType(linkType);
    linkIconGenerator.generateImage();
    linkIconGenerator.generateIcon();
    final JButton linkButton=new JButton(linkIconGenerator.getIcon());
    linkButton.setText(linkType.getName());
    linkButton.setToolTipText(linkType.getDescription());
    linkButtonPanel.add(linkButton);
    linkButton.addActionListener(new ActionListener(){
      @Override public void actionPerformed(      ActionEvent e){
        editBehaviourController.setLinkCreationMode(linkType);
        paletteGroup.setSelected(linkButton.getModel(),true);
      }
    }
);
  }
  this.setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
  this.splitPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT,this.palettePane,this.linkScrollPanel);
  this.splitPane.setOneTouchExpandable(true);
  this.splitPane.setDividerLocation(250);
  this.add(this.splitPane);
  editBehaviourController.addViewBehaviourModeChangeListener(new IViewBehaviourModeChangeListener(){
    @Override public void viewModeChange(    IViewBehaviourModeChangeEvent e){
      if (e.getNewModeType().equals(ModeType.SELECTION)) {
        paletteGroup.setSelected(selectionButton.getModel(),true);
      }
    }
  }
);
  paletteGroup.setSelected(selectionButton.getModel(),true);
}