Program: 102966
Project: 102966
Buggy source:
/** 
 * Creates basic controls for a type (AUDIO or VIDEO).
 * @param type the type.
 * @return the build Component.
 */
private Component createBasicControls(final int type){
  final boolean setAudioSystemIsDisabled=(type == DeviceConfigurationComboBoxModel.AUDIO) && NeomediaActivator.getConfigurationService().getBoolean(MediaServiceImpl.DISABLE_SET_AUDIO_SYSTEM_PNAME,false);
  final JComboBox deviceComboBox;
  final Container devicePanel;
  if (setAudioSystemIsDisabled) {
    deviceComboBox=null;
    devicePanel=null;
  }
 else {
    deviceComboBox=new JComboBox();
    deviceComboBox.setEditable(false);
    deviceComboBox.setModel(new DeviceConfigurationComboBoxModel(mediaService.getDeviceConfiguration(),type));
    JLabel deviceLabel=new JLabel(getLabelText(type));
    deviceLabel.setDisplayedMnemonic(getDisplayedMnemonic(type));
    deviceLabel.setLabelFor(deviceComboBox);
    devicePanel=new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
    devicePanel.setMaximumSize(new Dimension(WIDTH,25));
    devicePanel.add(deviceLabel);
    devicePanel.add(deviceComboBox);
  }
  final JPanel deviceAndPreviewPanel=new TransparentPanel(new BorderLayout());
  int preferredDeviceAndPreviewPanelHeight;
switch (type) {
case DeviceConfigurationComboBoxModel.AUDIO:
    preferredDeviceAndPreviewPanelHeight=(devicePanel == null) ? 200 : 245;
  break;
case DeviceConfigurationComboBoxModel.VIDEO:
preferredDeviceAndPreviewPanelHeight=305;
break;
default :
preferredDeviceAndPreviewPanelHeight=0;
break;
}
if (preferredDeviceAndPreviewPanelHeight > 0) {
deviceAndPreviewPanel.setPreferredSize(new Dimension(WIDTH,preferredDeviceAndPreviewPanelHeight));
}
if (devicePanel != null) deviceAndPreviewPanel.add(devicePanel,BorderLayout.NORTH);
final ActionListener deviceComboBoxActionListener=new ActionListener(){
public void actionPerformed(ActionEvent ev){
boolean revalidateAndRepaint=false;
for (int i=deviceAndPreviewPanel.getComponentCount() - 1; i >= 0; i--) {
Component c=deviceAndPreviewPanel.getComponent(i);
if (c != devicePanel) {
deviceAndPreviewPanel.remove(i);
revalidateAndRepaint=true;
}
}
Component preview=null;
if ((deviceComboBox == null) || ((deviceComboBox.getSelectedItem() != null) && deviceComboBox.isShowing())) {
preview=createPreview(type,deviceComboBox,deviceAndPreviewPanel.getPreferredSize());
}
if (preview != null) {
deviceAndPreviewPanel.add(preview,BorderLayout.CENTER);
revalidateAndRepaint=true;
}
if (revalidateAndRepaint) {
deviceAndPreviewPanel.revalidate();
deviceAndPreviewPanel.repaint();
}
}
}
;
if (deviceComboBox != null) deviceComboBox.addActionListener(deviceComboBoxActionListener);
deviceAndPreviewPanel.addHierarchyListener(new HierarchyListener(){
public void hierarchyChanged(HierarchyEvent event){
if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
SwingUtilities.invokeLater(new Runnable(){
public void run(){
deviceComboBoxActionListener.actionPerformed(null);
}
}
);
}
}
}
);
return deviceAndPreviewPanel;
}

Fixed version (ground truth):
/** 
 * Creates basic controls for a type (AUDIO or VIDEO).
 * @param type the type.
 * @return the build Component.
 */
private Component createBasicControls(final int type){
  final boolean setAudioSystemIsDisabled=(type == DeviceConfigurationComboBoxModel.AUDIO) && NeomediaActivator.getConfigurationService().getBoolean(MediaServiceImpl.DISABLE_SET_AUDIO_SYSTEM_PNAME,false);
  final DeviceComboBoxField deviceComboBox;
  final Container devicePanel;
  if (setAudioSystemIsDisabled) {
    deviceComboBox=null;
    devicePanel=null;
  }
 else {
    JLabel deviceLabel=new JLabel(getLabelText(type));
    deviceLabel.setDisplayedMnemonic(getDisplayedMnemonic(type));
    devicePanel=new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
    devicePanel.setMaximumSize(new Dimension(WIDTH,25));
    devicePanel.add(deviceLabel);
    deviceComboBox=new DeviceComboBoxField(type,devicePanel);
    deviceLabel.setLabelFor(deviceComboBox.getComponent());
  }
  final JPanel deviceAndPreviewPanel=new TransparentPanel(new BorderLayout());
  int preferredDeviceAndPreviewPanelHeight;
switch (type) {
case DeviceConfigurationComboBoxModel.AUDIO:
    preferredDeviceAndPreviewPanelHeight=(devicePanel == null) ? 200 : 245;
  break;
case DeviceConfigurationComboBoxModel.VIDEO:
preferredDeviceAndPreviewPanelHeight=305;
break;
default :
preferredDeviceAndPreviewPanelHeight=0;
break;
}
if (preferredDeviceAndPreviewPanelHeight > 0) {
deviceAndPreviewPanel.setPreferredSize(new Dimension(WIDTH,preferredDeviceAndPreviewPanelHeight));
}
if (devicePanel != null) deviceAndPreviewPanel.add(devicePanel,BorderLayout.NORTH);
final DeviceComboBoxField.Listener deviceComboBoxActionListener=new DeviceComboBoxField.Listener(){
public void onAction(){
boolean revalidateAndRepaint=false;
for (int i=deviceAndPreviewPanel.getComponentCount() - 1; i >= 0; i--) {
Component c=deviceAndPreviewPanel.getComponent(i);
if (c != devicePanel) {
deviceAndPreviewPanel.remove(i);
revalidateAndRepaint=true;
}
}
Component preview=null;
if ((deviceComboBox == null) || ((deviceComboBox.getSelectedItem() != null) && deviceComboBox.getComponent().isShowing())) {
preview=createPreview(type,deviceComboBox,deviceAndPreviewPanel.getPreferredSize());
}
if (preview != null) {
deviceAndPreviewPanel.add(preview,BorderLayout.CENTER);
revalidateAndRepaint=true;
}
if (revalidateAndRepaint) {
deviceAndPreviewPanel.revalidate();
deviceAndPreviewPanel.repaint();
}
}
}
;
if (deviceComboBox != null) deviceComboBox.addListener(deviceComboBoxActionListener);
deviceAndPreviewPanel.addHierarchyListener(new HierarchyListener(){
public void hierarchyChanged(HierarchyEvent event){
if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
SwingUtilities.invokeLater(new Runnable(){
public void run(){
deviceComboBoxActionListener.onAction();
}
}
);
}
}
}
);
return deviceAndPreviewPanel;
}