Program: 103407
Project: 103407
Buggy source:
/** 
 * Create preview component.
 * @param type type
 * @param comboBox the options.
 * @return the component.
 */
private static Component createPreview(int type,final JComboBox comboBox){
  final JComponent preview;
  if (type == DeviceConfigurationComboBoxModel.VIDEO) {
    JLabel noPreview=new JLabel(NeomediaActivator.getResources().getI18NString("String_Node_Str"));
    noPreview.setHorizontalAlignment(SwingConstants.CENTER);
    noPreview.setVerticalAlignment(SwingConstants.CENTER);
    preview=createVideoContainer(noPreview);
    preview.setPreferredSize(new Dimension(WIDTH,280));
    preview.setMaximumSize(new Dimension(WIDTH,280));
    final ActionListener comboBoxListener=new ActionListener(){
      public void actionPerformed(      ActionEvent event){
        Object selection=comboBox.getSelectedItem();
        CaptureDeviceInfo device=null;
        if (selection instanceof DeviceConfigurationComboBoxModel.CaptureDevice)         device=((DeviceConfigurationComboBoxModel.CaptureDevice)selection).info;
        ((DeviceConfigurationComboBoxModel)comboBox.getModel()).reinitVideo();
        if ((device != null) && device.equals(videoDeviceInPreview))         return;
        Exception exception;
        try {
          createPreview(device,preview);
          exception=null;
        }
 catch (        IOException ex) {
          exception=ex;
        }
catch (        MediaException ex) {
          exception=ex;
        }
        if (exception != null) {
          logger.error("String_Node_Str" + device,exception);
          device=null;
        }
        videoDeviceInPreview=device;
      }
    }
;
    comboBox.addActionListener(comboBoxListener);
    comboBox.addHierarchyListener(new HierarchyListener(){
      public void hierarchyChanged(      HierarchyEvent event){
        if (((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) && comboBox.isDisplayable()) {
          SwingUtilities.invokeLater(new Runnable(){
            public void run(){
              comboBoxListener.actionPerformed(null);
            }
          }
);
        }
 else {
          if (!comboBox.isDisplayable())           videoDeviceInPreview=null;
        }
      }
    }
);
  }
 else   preview=new TransparentPanel();
  return preview;
}

Fixed version (ground truth):
/** 
 * Create preview component.
 * @param type type
 * @param comboBox the options.
 * @return the component.
 */
private static Component createPreview(int type,final JComboBox comboBox){
  final JComponent preview;
  if (type == DeviceConfigurationComboBoxModel.VIDEO) {
    JLabel noPreview=new JLabel(NeomediaActivator.getResources().getI18NString("String_Node_Str"));
    noPreview.setHorizontalAlignment(SwingConstants.CENTER);
    noPreview.setVerticalAlignment(SwingConstants.CENTER);
    preview=createVideoContainer(noPreview);
    preview.setPreferredSize(new Dimension(WIDTH,280));
    preview.setMaximumSize(new Dimension(WIDTH,280));
    final ActionListener comboBoxListener=new ActionListener(){
      public void actionPerformed(      ActionEvent event){
        Object selection=comboBox.getSelectedItem();
        CaptureDeviceInfo device=null;
        if (selection instanceof DeviceConfigurationComboBoxModel.CaptureDevice)         device=((DeviceConfigurationComboBoxModel.CaptureDevice)selection).info;
        ((DeviceConfigurationComboBoxModel)comboBox.getModel()).reinitVideo();
        if ((device != null) && device.equals(videoDeviceInPreview))         return;
        Exception exception;
        try {
          createPreview(device,preview);
          exception=null;
        }
 catch (        IOException ex) {
          exception=ex;
        }
catch (        MediaException ex) {
          exception=ex;
        }
        if (exception != null) {
          logger.error("String_Node_Str" + device,exception);
          device=null;
        }
        videoDeviceInPreview=device;
      }
    }
;
    comboBox.addActionListener(comboBoxListener);
    HierarchyListener hierarchyListener=new HierarchyListener(){
      private Window window;
      private WindowListener windowListener;
      public void dispose(){
        if (windowListener != null) {
          if (window != null) {
            window.removeWindowListener(windowListener);
            window=null;
          }
          windowListener=null;
        }
        videoDeviceInPreview=null;
      }
      public void hierarchyChanged(      HierarchyEvent event){
        if ((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == 0)         return;
        if (comboBox.isDisplayable()) {
          SwingUtilities.invokeLater(new Runnable(){
            public void run(){
              comboBoxListener.actionPerformed(null);
            }
          }
);
          if (windowListener == null) {
            window=SwingUtilities.windowForComponent(comboBox);
            if (window != null) {
              windowListener=new WindowAdapter(){
                @Override public void windowClosing(                WindowEvent event){
                  dispose();
                }
              }
;
              window.addWindowListener(windowListener);
            }
          }
        }
 else {
          dispose();
        }
      }
    }
;
    comboBox.addHierarchyListener(hierarchyListener);
  }
 else   preview=new TransparentPanel();
  return preview;
}