Program: 31212
Project: 31212
Buggy source:
public void displayDetailedChart(SparklineData data,boolean openNewChart,boolean newAxis){
  Trace2DLtd trace=(Trace2DLtd)data.chart.getTraces().first();
  for (  ZoomableChartScrollWheel chart : chartData.getCharts()) {
    if (chart.getTraces().contains(trace)) {
      chart.toFront();
      return;
    }
  }
  if (openNewChart || chartData.getCharts().size() < 1) {
    JFrame frame=new JFrame(data.name);
    final ZoomableChartScrollWheel newChart=new ZoomableChartScrollWheel(chartData);
    trace.setMaxSize(chartData.detailedSparklineChartSize);
    trace.setColor(chartData.popColor());
    newChart.addTrace(trace);
    newChart.updateRightClickMenu();
    chartData.getCharts().add(newChart);
    Container content=frame.getContentPane();
    content.add(newChart);
    newChart.addFrameFocusTimer(frame);
    frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(      WindowEvent e){
        for (        ITrace2D trace : newChart.getTraces()) {
          ((Trace2DLtd)trace).setMaxSize(chartData.sparklineChartSize);
        }
        chartData.getCharts().remove(newChart);
      }
    }
);
    frame.setSize(600,500);
    frame.setVisible(true);
  }
 else {
    long bestFocusTime=-1;
    ZoomableChartScrollWheel bestChart=null;
    for (    ZoomableChartScrollWheel chart : chartData.getCharts()) {
      if (chart.getLastFocusTime() > bestFocusTime) {
        bestFocusTime=chart.getLastFocusTime();
        bestChart=chart;
      }
    }
    if (bestChart != null) {
      if (!bestChart.getTraces().contains(trace)) {
        trace.setMaxSize(chartData.detailedSparklineChartSize);
        trace.setColor(chartData.popColor());
        if (newAxis) {
          AxisLinear axis=new AxisLinear();
          bestChart.addAxisYRight(axis);
          bestChart.addTrace(trace,bestChart.getAxisX(),axis);
        }
 else {
          bestChart.addTrace(trace);
        }
      }
      bestChart.updateRightClickMenu();
      bestChart.toFront();
    }
  }
}

Fixed version (ground truth):
public void displayDetailedChart(SparklineData data,boolean openNewChart,boolean newAxis){
  Trace2DLtd trace=(Trace2DLtd)data.chart.getTraces().first();
  for (  ZoomableChartScrollWheel chart : chartData.getCharts()) {
    if (chart.getTraces().contains(trace)) {
      chart.toFront();
      return;
    }
  }
  if (openNewChart || chartData.getCharts().size() < 1) {
    ZoomableChartScrollWheel.newChartFrame(chartData,trace);
  }
 else {
    long bestFocusTime=-1;
    ZoomableChartScrollWheel bestChart=null;
    for (    ZoomableChartScrollWheel chart : chartData.getCharts()) {
      if (chart.getLastFocusTime() > bestFocusTime) {
        bestFocusTime=chart.getLastFocusTime();
        bestChart=chart;
      }
    }
    if (bestChart != null) {
      if (!bestChart.getTraces().contains(trace)) {
        trace.setMaxSize(chartData.detailedSparklineChartSize);
        trace.setColor(chartData.popColor());
        if (newAxis) {
          AxisLinear axis=new AxisLinear();
          bestChart.addAxisYRight(axis);
          bestChart.addTrace(trace,bestChart.getAxisX(),axis);
        }
 else {
          bestChart.addTrace(trace);
        }
      }
      bestChart.updateRightClickMenu();
      bestChart.toFront();
    }
  }
}