Program: 31077
Project: 31077
Buggy source:
ConfirmDialog(Component parentComponent,Object message,String title,int optionType,Icon icon){
  super();
  super.addKeyListener(this);
  int NrOfButtons;
  MyComp=null;
  String YesText="String_Node_Str";
  String NoText="String_Node_Str";
  String CancelText="String_Node_Str";
  Boolean YesButtonV=false;
  Boolean NoButtonV=false;
  Boolean CancelButtonV=false;
  IsOkButton=false;
switch (optionType) {
case JOptionPane.OK_CANCEL_OPTION:
    YesText="String_Node_Str";
  IsOkButton=true;
YesButtonV=true;
CancelButtonV=true;
NrOfButtons=2;
break;
case JOptionPane.YES_NO_OPTION:
YesButtonV=true;
NoButtonV=true;
NrOfButtons=2;
break;
case JOptionPane.YES_NO_CANCEL_OPTION:
YesButtonV=true;
NoButtonV=true;
CancelButtonV=true;
NrOfButtons=3;
default :
NrOfButtons=1;
break;
}
if (parentComponent != null) {
parentComponent.addComponentListener(this);
parentComponent.addKeyListener(this);
}
setModal(true);
setResizable(false);
GridBagLayout thisLayout=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
setLayout(thisLayout);
setTitle(title);
gbc.gridx=0;
gbc.gridy=0;
gbc.gridwidth=NrOfButtons;
if (message instanceof JScrollPane) add((JScrollPane)message,gbc);
 else if (message instanceof JPanel) {
MyComp=(JPanel)message;
MyComp.addComponentListener(this);
for (Component comp : MyComp.getComponents()) comp.addKeyListener(this);
add((JPanel)message,gbc);
}
 else add(new ScaledLabel(message.toString(),icon,JLabel.LEFT),gbc);
gbc.gridy=1;
add(new ScaledLabel("String_Node_Str"),gbc);
gbc.gridy=2;
gbc.gridx=0;
gbc.gridwidth=1;
gbc.insets=new Insets(0,AppPreferences.getScaled(5),0,AppPreferences.getScaled(5));
gbc.fill=GridBagConstraints.HORIZONTAL;
YesButton=new ScaledButton(YesText);
YesButton.setActionCommand("String_Node_Str");
YesButton.addActionListener(this);
YesButton.addKeyListener(this);
NoButton=new ScaledButton(NoText);
NoButton.setActionCommand("String_Node_Str");
NoButton.addActionListener(this);
NoButton.addKeyListener(this);
CancelButton=new ScaledButton(CancelText);
CancelButton.setActionCommand("String_Node_Str");
CancelButton.addActionListener(this);
CancelButton.addKeyListener(this);
if (YesButtonV) {
add(YesButton,gbc);
gbc.gridx++;
}
if (NoButtonV) {
add(NoButton,gbc);
gbc.gridx++;
}
if (CancelButtonV) {
add(CancelButton,gbc);
gbc.gridx++;
}
gbc.gridwidth=NrOfButtons;
gbc.gridy=3;
add(new ScaledLabel("String_Node_Str"),gbc);
pack();
setPreferredSize(new Dimension(getWidth() + 2 * AppPreferences.getScaled(getFont().getSize()),getHeight()));
if (parentComponent != null) this.setLocationRelativeTo(parentComponent);
 else {
PointerInfo mouseloc=MouseInfo.getPointerInfo();
Point mlocation=mouseloc.getLocation();
int xpos=mlocation.x;
int ypos=mlocation.y;
xpos-=getWidth() >> 1;
ypos-=getHeight() >> 1;
if (xpos < 0) xpos=0;
if (ypos < 0) ypos=0;
setLocation(xpos,ypos);
}
}

Fixed version (ground truth):
ConfirmDialog(Component parentComponent,Object message,String title,int optionType,Icon icon){
  super();
  super.addKeyListener(this);
  int NrOfButtons;
  MyComp=null;
  String YesText="String_Node_Str";
  String NoText="String_Node_Str";
  String CancelText="String_Node_Str";
  Boolean YesButtonV=false;
  Boolean NoButtonV=false;
  Boolean CancelButtonV=false;
  IsOkButton=false;
switch (optionType) {
case JOptionPane.OK_CANCEL_OPTION:
    YesText="String_Node_Str";
  IsOkButton=true;
YesButtonV=true;
CancelButtonV=true;
NrOfButtons=2;
break;
case JOptionPane.YES_NO_OPTION:
YesButtonV=true;
NoButtonV=true;
NrOfButtons=2;
break;
case JOptionPane.YES_NO_CANCEL_OPTION:
YesButtonV=true;
NoButtonV=true;
CancelButtonV=true;
NrOfButtons=3;
default :
NrOfButtons=1;
break;
}
if (parentComponent != null) {
parentComponent.addComponentListener(this);
parentComponent.addKeyListener(this);
}
setModal(true);
setResizable(false);
GridBagLayout thisLayout=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
setLayout(thisLayout);
setTitle(title);
gbc.gridx=0;
gbc.gridy=0;
gbc.gridwidth=NrOfButtons;
if (message instanceof JScrollPane) add((JScrollPane)message,gbc);
 else if (message instanceof JPanel) {
MyComp=(JPanel)message;
MyComp.addComponentListener(this);
for (Component comp : MyComp.getComponents()) comp.addKeyListener(this);
add((JPanel)message,gbc);
}
 else add(new ScaledLabel(message.toString(),icon,JLabel.LEFT),gbc);
gbc.gridy=1;
add(new ScaledLabel("String_Node_Str"),gbc);
gbc.gridy=2;
gbc.gridx=0;
gbc.gridwidth=1;
gbc.insets=new Insets(0,AppPreferences.getScaled(5),0,AppPreferences.getScaled(5));
gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.weightx=1.0;
YesButton=new ScaledButton(YesText);
YesButton.setActionCommand("String_Node_Str");
YesButton.addActionListener(this);
YesButton.addKeyListener(this);
NoButton=new ScaledButton(NoText);
NoButton.setActionCommand("String_Node_Str");
NoButton.addActionListener(this);
NoButton.addKeyListener(this);
CancelButton=new ScaledButton(CancelText);
CancelButton.setActionCommand("String_Node_Str");
CancelButton.addActionListener(this);
CancelButton.addKeyListener(this);
if (YesButtonV) {
add(YesButton,gbc);
gbc.gridx++;
}
if (NoButtonV) {
add(NoButton,gbc);
gbc.gridx++;
}
if (CancelButtonV) {
add(CancelButton,gbc);
gbc.gridx++;
}
gbc.gridwidth=NrOfButtons;
gbc.gridy=3;
add(new ScaledLabel("String_Node_Str"),gbc);
pack();
setSize(new Dimension(getWidth() + 2 * AppPreferences.getScaled(getFont().getSize()),getHeight()));
if (parentComponent != null) this.setLocationRelativeTo(parentComponent);
 else {
PointerInfo mouseloc=MouseInfo.getPointerInfo();
Point mlocation=mouseloc.getLocation();
int xpos=mlocation.x;
int ypos=mlocation.y;
xpos-=getWidth() >> 1;
ypos-=getHeight() >> 1;
if (xpos < 0) xpos=0;
if (ypos < 0) ypos=0;
setLocation(xpos,ypos);
}
}