nus-yam/ex-repair huggingface dataset:
Program: 1193
Project: 1193
Buggy source:
public void addText(String addtext) throws IOException {
  String wrappedtext="String_Node_Str";
  int linecounter=0;
  String[] parts=addtext.split(newLine);
  ArrayList<String> finaltext=new ArrayList<String>();
  int width=Display.getWidth() - 8;
  int charCount=(int)(width / 7);
  for (int i=0; i < parts.length; i++) {
    if (parts[i].length() > charCount) {
      int endpoint=charCount;
      int beginpoint=0;
      while (endpoint > beginpoint) {
        for (int j=endpoint; j > beginpoint; j--) {
          Character ch=parts[i].charAt(j);
          if (Character.isSpaceChar(ch)) {
            endpoint=j;
            break;
          }
 else {
switch (ch) {
case '.':
case '?':
case ';':
case ':':
case '\t':
case '!':
              endpoint=j;
            break;
        }
      }
    }
    finaltext.add(parts[i].substring(beginpoint,endpoint) + newLine);
    linecounter++;
    beginpoint=endpoint + 1;
    endpoint=beginpoint + charCount;
    if (endpoint > parts[i].length() - 1) {
      finaltext.add(parts[i].substring(beginpoint,parts[i].length() - 1) + newLine);
      linecounter++;
      endpoint=-1;
    }
  }
}
 else {
  finaltext.add(parts[i] + newLine);
  linecounter++;
}
}
Gson gson=new Gson();
JsonWriter writer=new JsonWriter(new FileWriter("String_Node_Str"));
writer.beginArray();
Iterator e=finaltext.iterator();
while (e.hasNext()) {
gson.toJson(e.next(),String.class,writer);
}
writer.endArray();
writer.close();
}

Fixed version (ground truth):
public void addText(String addtext) throws IOException {
  String wrappedtext="String_Node_Str";
  int linecounter=0;
  String[] parts=addtext.split(newLine);
  ArrayList<String> finaltext=new ArrayList<String>();
  int width=Display.getWidth() - 8;
  int charCount=(int)(width / 7);
  for (int i=0; i < parts.length; i++) {
    if (parts[i].length() > charCount) {
      int endpoint=charCount;
      int beginpoint=0;
      while (endpoint > beginpoint) {
        for (int j=endpoint; j > beginpoint; j--) {
          Character ch=parts[i].charAt(j);
          if (Character.isSpaceChar(ch)) {
            endpoint=j;
            break;
          }
 else {
switch (ch) {
case '.':
case '?':
case ';':
case ':':
case '\t':
case '!':
              endpoint=j;
            break;
        }
      }
    }
    finaltext.add(parts[i].substring(beginpoint,endpoint) + newLine);
    linecounter++;
    beginpoint=endpoint + 1;
    endpoint=beginpoint + charCount;
    if (endpoint > parts[i].length() - 1) {
      finaltext.add(parts[i].substring(beginpoint,parts[i].length()) + newLine);
      linecounter++;
      endpoint=-1;
    }
  }
}
 else {
  finaltext.add(parts[i] + newLine);
  linecounter++;
}
}
Gson gson=new Gson();
JsonWriter writer=new JsonWriter(new FileWriter("String_Node_Str"));
writer.beginArray();
Iterator e=finaltext.iterator();
while (e.hasNext()) {
gson.toJson(e.next(),String.class,writer);
}
writer.endArray();
writer.close();
}
Program: 1194
Project: 1194
Buggy source:
public void renderWithLightValue(float light){
  if (isInvisible())   return;
  ShaderProgram shader=ShaderManager.getInstance().getShaderProgram("String_Node_Str");
  shader.enable();
  shader.setFloat("String_Node_Str",light);
  if (_mesh == null) {
    Tessellator tessellator=new Tessellator();
    tessellator.setColor(new Vector4f(1,1,1,1));
    if (_centerMesh != null) {
      tessellator.addMeshPart(_centerMesh);
    }
    for (    Side dir : Side.values()) {
      BlockMeshPart part=_sideMesh.get(dir);
      if (part != null) {
        float lightLevel=DIRECTION_LIT_LEVEL.get(dir);
        tessellator.setColor(new Vector4f(lightLevel,lightLevel,lightLevel,lightLevel));
        tessellator.addMeshPart(part);
      }
    }
    _mesh=tessellator.generateMesh();
  }
  if (getBlockForm() != BLOCK_FORM.BILLBOARD) {
    _mesh.render();
  }
 else {
    glDisable(GL11.GL_CULL_FACE);
    _mesh.render();
    glEnable(GL11.GL_CULL_FACE);
  }
}

Fixed version (ground truth):
public void renderWithLightValue(float light){
  if (isInvisible())   return;
  ShaderProgram shader=ShaderManager.getInstance().getShaderProgram("String_Node_Str");
  shader.enable();
  shader.setFloat("String_Node_Str",light);
  if (_mesh == null) {
    Tessellator tessellator=new Tessellator();
    tessellator.setColor(new Vector4f(1,1,1,1));
    if (_centerMesh != null) {
      tessellator.addMeshPart(_centerMesh);
    }
    for (    Side dir : Side.values()) {
      BlockMeshPart part=_sideMesh.get(dir);
      if (part != null) {
        float lightLevel=DIRECTION_LIT_LEVEL.get(dir);
        tessellator.setColor(new Vector4f(lightLevel,lightLevel,lightLevel,lightLevel));
        tessellator.addMeshPart(part);
      }
    }
    _mesh=tessellator.generateMesh();
  }
  if (getBlockForm() != BLOCK_FORM.BILLBOARD || !glIsEnabled(GL11.GL_CULL_FACE)) {
    _mesh.render();
  }
 else {
    glDisable(GL11.GL_CULL_FACE);
    _mesh.render();
    glEnable(GL11.GL_CULL_FACE);
  }
}
Program: 1195
Project: 1195
Buggy source:
public HashMap<Byte,String> getGroovyBlocks(){
  HashMap<Byte,String> retval=new HashMap<Byte,String>();
  for (byte i=-127; i < 128; i++) {
    Block b=BlockManager.getInstance().getBlock(i);
    if (b.getId() != 0) {
      retval.put(b.getId(),b.getTitle());
    }
    if (i == 117) {
      break;
    }
  }
  return retval;
}

Fixed version (ground truth):
public HashMap<Byte,String> getGroovyBlocks(){
  HashMap<Byte,String> retval=new HashMap<Byte,String>();
  String[] endfilter={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  String fampref="String_Node_Str";
  String tempval="String_Node_Str";
  boolean nodup=true;
  for (byte i=-127; i < 127; i++) {
    Block b=BlockManager.getInstance().getBlock(i);
    if (b.getId() != 0) {
      if (tempval.length() > 0) {
        if (b.getTitle().startsWith(tempval)) {
          nodup=false;
        }
 else {
          nodup=true;
          tempval="String_Node_Str";
        }
      }
 else {
        for (int j=0; j < endfilter.length; j++) {
          if (b.getTitle().endsWith(endfilter[j])) {
            tempval=b.getTitle().substring(0,b.getTitle().length() - endfilter[j].length());
          }
        }
      }
      if (nodup) {
        String tempfam=b.getBlockFamily().toString().split("String_Node_Str")[0];
        if (tempfam.startsWith(fampref)) {
          tempfam=tempfam.substring(fampref.length(),tempfam.length());
        }
        if (tempval.length() < 1) {
          retval.put(b.getId(),b.getTitle() + "String_Node_Str" + tempfam);
        }
 else {
          retval.put(b.getId(),tempval + "String_Node_Str" + tempfam);
        }
      }
    }
    if (i == 127) {
      break;
    }
  }
  return retval;
}
Program: 1196
Project: 1196
Buggy source:
@Override public void update(){
  if (_wheelMoved != 0) {
    if (_wheelMoved == 120) {
      currentpos++;
    }
 else {
      currentpos--;
    }
    _wheelMoved=0;
    try {
      showFromJson();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void update(){
  if (wheelycount != 0) {
    currentpos+=wheelycount;
    wheelycount=0;
    try {
      showFromJson();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
Program: 1197
Project: 1197
Buggy source:
public void showFromJson() throws IOException {
  int maxlines=getLineCount();
  int screenlines=getScreenLines();
  long beginpos, endpos, counter;
  if (screenlines + currentpos > maxlines) {
    beginpos=-1;
  }
 else {
    beginpos=maxlines - (screenlines + currentpos) + 1;
  }
  endpos=beginpos + screenlines;
  if (endpos > maxlines) {
    endpos=maxlines + 1;
  }
  counter=0;
  Gson gson=new Gson();
  JsonReader reader=new JsonReader(new FileReader("String_Node_Str"));
  reader.beginArray();
  _text="String_Node_Str";
  while (reader.hasNext()) {
    if (counter > beginpos && counter < endpos) {
      _text+=gson.fromJson(reader,String.class);
    }
 else {
      gson.fromJson(reader,String.class);
    }
    counter++;
  }
  reader.endArray();
  reader.close();
}

Fixed version (ground truth):
public void showFromJson() throws IOException {
  int maxlines=getLineCount();
  int screenlines=getScreenLines();
  long beginpos, endpos, counter;
  if (screenlines > maxlines) {
    beginpos=-1;
  }
 else {
    if (currentpos < 0) {
      currentpos=0;
    }
    if (currentpos > maxlines - screenlines) {
      currentpos=maxlines - screenlines;
    }
    beginpos=maxlines - (screenlines + currentpos) - 1;
  }
  endpos=beginpos + screenlines + 1;
  counter=0;
  Gson gson=new Gson();
  JsonReader reader=new JsonReader(new FileReader("String_Node_Str"));
  reader.beginArray();
  _text="String_Node_Str";
  while (reader.hasNext()) {
    if (counter > beginpos && counter < endpos) {
      _text+=gson.fromJson(reader,String.class);
    }
 else {
      gson.fromJson(reader,String.class);
    }
    counter++;
  }
  reader.endArray();
  reader.close();
}
Program: 1198
Project: 1198
Buggy source:
private void getHelp(String commandstring) throws IOException {
  String[] split=commandstring.split("String_Node_Str");
  if (split.length > 1) {
    if (split[1].equals("String_Node_Str")) {
      GroovyHelpManager groovyhelpmanager=new GroovyHelpManager();
      HashMap<String,String> commandhelp=groovyhelpmanager.getHelpCommands();
      String[] commandlist=groovyhelpmanager.getGroovyCommands();
      String retval="String_Node_Str" + newLine + newLine;
      for (int i=0; i < commandlist.length; i++) {
        if (commandhelp.containsKey(commandlist[i])) {
          retval+=commandlist[i].toString() + "String_Node_Str" + commandhelp.get(commandlist[i]).toString()+ newLine;
        }
 else {
          retval+=commandlist[i].toString() + "String_Node_Str" + newLine;
        }
      }
      setHelpText(retval);
      return;
    }
    GroovyHelpManager groovyhelpmanager=new GroovyHelpManager();
    if (groovyhelpmanager.getHelpCommands().containsKey(split[1])) {
      GroovyHelp groovyhelp=groovyhelpmanager.readCommandHelp(split[1]);
      setHelpText(groovyhelp);
      return;
    }
    if (split[1].equals("String_Node_Str")) {
      String tempval="String_Node_Str";
      HashMap<Byte,String> blocks=groovyhelpmanager.getGroovyBlocks();
      for (byte i=0; i < blocks.size(); i++) {
        tempval+="String_Node_Str" + blocks.get(i) + "String_Node_Str"+ i+ newLine;
      }
      setHelpText(tempval);
      return;
    }
    showError();
  }
 else {
    showHelp();
  }
}

Fixed version (ground truth):
private void getHelp(String commandstring) throws IOException {
  String[] split=commandstring.split("String_Node_Str");
  if (split.length > 1) {
    if (split[1].equals("String_Node_Str")) {
      GroovyHelpManager groovyhelpmanager=new GroovyHelpManager();
      HashMap<String,String> commandhelp=groovyhelpmanager.getHelpCommands();
      String[] commandlist=groovyhelpmanager.getGroovyCommands();
      String retval="String_Node_Str" + newLine + newLine;
      for (int i=0; i < commandlist.length; i++) {
        if (commandhelp.containsKey(commandlist[i])) {
          retval+=commandlist[i].toString() + "String_Node_Str" + commandhelp.get(commandlist[i]).toString()+ newLine;
        }
 else {
          retval+=commandlist[i].toString() + "String_Node_Str" + newLine;
        }
      }
      setHelpText(retval);
      return;
    }
    GroovyHelpManager groovyhelpmanager=new GroovyHelpManager();
    if (groovyhelpmanager.getHelpCommands().containsKey(split[1])) {
      GroovyHelp groovyhelp=groovyhelpmanager.readCommandHelp(split[1]);
      setHelpText(groovyhelp);
      return;
    }
    if (split[1].equals("String_Node_Str")) {
      String tempval="String_Node_Str";
      HashMap<Byte,String> blocks=groovyhelpmanager.getGroovyBlocks();
      for (byte i=0; i < Byte.MAX_VALUE; i++) {
        if (blocks.containsKey(i)) {
          tempval+="String_Node_Str" + blocks.get(i) + "String_Node_Str"+ i+ newLine;
        }
      }
      setHelpText(tempval);
      return;
    }
    showError();
  }
 else {
    showHelp();
  }
}
Program: 1199
Project: 1199
Buggy source:
private void setupSelectWorldMenu(){
  _selectWorldMenu=new UISelectWorldMenu();
  _selectWorldMenu.setVisible(false);
  UIButton goToBack=(UIButton)_selectWorldMenu.getElementById("String_Node_Str");
  goToBack.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _selectWorldMenu.setVisible(false);
      _mainMenu.setVisible(true);
    }
  }
);
}

Fixed version (ground truth):
private void setupSelectWorldMenu(){
  _selectWorldMenu=new UISelectWorldMenu();
  _selectWorldMenu.setVisible(false);
  UIButton goToBack=(UIButton)_selectWorldMenu.getElementById("String_Node_Str");
  goToBack.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      GUIManager.getInstance().setFocusedWindow(_mainMenu);
    }
  }
);
}
Program: 1200
Project: 1200
Buggy source:
public void activate(){
  Mouse.setGrabbed(false);
  playBackgroundMusic();
  UIButton graphicsQualityButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  UIButton FOVButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  UIButton viewingDistanceButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  if (Config.getInstance().getActiveViewingDistanceId() == 3)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 1)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 2)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   viewingDistanceButton.getLabel().setText("String_Node_Str");
  if (Config.getInstance().getGraphicsQuality() == 1)   graphicsQualityButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getGraphicsQuality() == 2)   graphicsQualityButton.getLabel().setText("String_Node_Str");
 else   graphicsQualityButton.getLabel().setText("String_Node_Str");
  FOVButton.getLabel().setText("String_Node_Str" + (int)Config.getInstance().getFov());
}

Fixed version (ground truth):
public void activate(){
  Mouse.setGrabbed(false);
  playBackgroundMusic();
  GUIManager.getInstance().getWindowById("String_Node_Str").setVisible(true);
  GUIManager.getInstance().getWindowById("String_Node_Str").setVisible(false);
  GUIManager.getInstance().getWindowById("String_Node_Str").setVisible(false);
  GUIManager.getInstance().getWindowById("String_Node_Str").setVisible(false);
  GUIManager.getInstance().setFocusedWindow("String_Node_Str");
  UIButton graphicsQualityButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  UIButton FOVButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  UIButton viewingDistanceButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  if (Config.getInstance().getActiveViewingDistanceId() == 3)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 1)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 2)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   viewingDistanceButton.getLabel().setText("String_Node_Str");
  if (Config.getInstance().getGraphicsQuality() == 1)   graphicsQualityButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getGraphicsQuality() == 2)   graphicsQualityButton.getLabel().setText("String_Node_Str");
 else   graphicsQualityButton.getLabel().setText("String_Node_Str");
  FOVButton.getLabel().setText("String_Node_Str" + (int)Config.getInstance().getFov());
}
Program: 1201
Project: 1201
Buggy source:
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  UIButton singlePlayerButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton configButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton exitButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  singlePlayerButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _selectWorldMenu.setVisible(true);
    }
  }
);
  exitButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  configButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _configMenu.setVisible(true);
    }
  }
);
}

Fixed version (ground truth):
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  UIButton singlePlayerButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton configButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton exitButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  singlePlayerButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      GUIManager.getInstance().setFocusedWindow(_selectWorldMenu);
    }
  }
);
  exitButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  configButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      GUIManager.getInstance().setFocusedWindow(_configMenu);
    }
  }
);
}
Program: 1202
Project: 1202
Buggy source:
private void setTopWindow(int windowPosition){
  _lastFocused=_focusedWindow;
  _focusedWindow=(UIDisplayWindow)_renderer.getDisplayElements().get(windowPosition);
  if (!_focusedWindow.isMaximized()) {
    _renderer.changeElementDepth(windowPosition,_renderer.getDisplayElements().size() - 1);
  }
}

Fixed version (ground truth):
private void setTopWindow(int windowPosition){
  if (_renderer.getDisplayElements().size() - 1 < windowPosition || windowPosition < 0) {
    return;
  }
  UIDisplayWindow setTopWindow=(UIDisplayWindow)_renderer.getDisplayElements().get(windowPosition);
  if (setTopWindow == null) {
    return;
  }
  if (_lastFocused != null && _lastFocused.equals(setTopWindow)) {
    return;
  }
  _lastFocused=_focusedWindow;
  if (_lastFocused != null && _lastFocused.isMaximized() && setTopWindow.isMaximized()) {
    _lastFocused.setVisible(false);
  }
  _focusedWindow=setTopWindow;
  if (!_focusedWindow.isMaximized()) {
    _renderer.changeElementDepth(windowPosition,_renderer.getDisplayElements().size() - 1);
  }
  if (!_focusedWindow.isVisible()) {
    _focusedWindow.setVisible(true);
  }
}
Program: 1203
Project: 1203
Buggy source:
public void resize(){
  _title.setSize(new Vector2f(getSize().x * 0.85f,19f));
  _title.getPosition().x=(getPosition().x + getSize().x / 2f) - _title.getSize().x / 2;
  _title.resize();
  _style=null;
  _close.getPosition().x=getSize().x - 25f;
  windowStyleSetup();
}

Fixed version (ground truth):
public void resize(){
  _title.setSize(new Vector2f(getSize().x * 0.55f,19f));
  _title.getPosition().x=getSize().x / 2f - _title.getSize().x / 2;
  _title.resize();
  _style=null;
  _close.getPosition().x=getSize().x - 25f;
  windowStyleSetup();
}
Program: 1204
Project: 1204
Buggy source:
public void clearData(){
  if (_inputValue.length() > 0) {
    _inputValue.delete(0,_inputValue.length() - 1);
  }
  _inputText.setText("String_Node_Str");
}

Fixed version (ground truth):
public void clearData(){
  if (_inputValue.length() > 0) {
    _inputValue.delete(0,_inputValue.length() - 1);
  }
  _cursorPosition=0;
  _inputText.setText("String_Node_Str");
}
Program: 1205
Project: 1205
Buggy source:
public UIList(Vector2f size){
  setSize(size);
  setCrop(true);
  setScrollBarsPosition(getPosition(),getSize());
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setCropMargin(new Vector4f(-15f,-15f,0,0));
}

Fixed version (ground truth):
public UIList(Vector2f size){
  setSize(size);
  setCrop(true);
  setScrollBarsPosition(getPosition(),getSize());
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setStyle("String_Node_Str","String_Node_Str");
  setCropMargin(new Vector4f(-15f,-15f,-15f,0));
}
Program: 1206
Project: 1206
Buggy source:
public void update(){
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  if (intersects(mousePos)) {
    boolean itemClicked=false;
    for (int i=(_items.size() - 1); i >= 0; i--) {
      UIListItem item=_items.get(i);
      if (item.isVisible()) {
        if (item.intersects(mousePos)) {
          if (_mouseDown) {
            if (item.isSelected()) {
              break;
            }
            if (_selectedItemIndex >= 0) {
              _items.get(_selectedItemIndex).setSelected(false);
            }
            item.setSelected(true);
            _selectedItemIndex=i;
            _mouseDown=false;
            itemClicked=true;
          }
        }
      }
    }
    if (!itemClicked) {
      _mouseUp=false;
      _mouseDown=false;
    }
  }
 else {
    _mouseUp=false;
    _mouseDown=false;
  }
  super.update();
}

Fixed version (ground truth):
public void update(){
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  if (intersects(mousePos)) {
    if (_scrollBarVertical.intersects(mousePos) || _scrollBarHorizontal.intersects(mousePos)) {
      return;
    }
    boolean itemClicked=false;
    for (int i=(_items.size() - 1); i >= 0; i--) {
      UIListItem item=_items.get(i);
      if (item.isVisible()) {
        if (item.intersects(mousePos)) {
          if (_mouseDown) {
            if (item.isSelected()) {
              doubleClick();
              break;
            }
            if (_selectedItemIndex >= 0) {
              _items.get(_selectedItemIndex).setSelected(false);
            }
            item.setSelected(true);
            _selectedItemIndex=i;
            _mouseDown=false;
            itemClicked=true;
          }
        }
      }
    }
    if (!itemClicked) {
      _mouseUp=false;
      _mouseDown=false;
    }
  }
 else {
    _wheelMoved=0;
    _mouseUp=false;
    _mouseDown=false;
  }
  super.update();
}
Program: 1207
Project: 1207
Buggy source:
public UIListItem getSelectedItem(){
  return _items.get(_selectedItemIndex);
}

Fixed version (ground truth):
public UIListItem getSelectedItem(){
  if (_selectedItemIndex < 0) {
    return null;
  }
  return _items.get(_selectedItemIndex);
}
Program: 1208
Project: 1208
Buggy source:
public void init(){
  _gameInstance=Terasology.getInstance();
  setupMainMenu();
  setupSelectWorldMenu();
  setupConfigMenu();
  _mainMenu.name="String_Node_Str";
  _configMenu.name="String_Node_Str";
  _selectWorldMenu.name="String_Node_Str";
  GUIManager.getInstance().addWindow(_mainMenu,"String_Node_Str");
  GUIManager.getInstance().addWindow(_configMenu,"String_Node_Str");
  GUIManager.getInstance().addWindow(_selectWorldMenu,"String_Node_Str");
}

Fixed version (ground truth):
public void init(){
  _gameInstance=Terasology.getInstance();
  setupMainMenu();
  setupSelectWorldMenu();
  setupConfigMenu();
  GUIManager.getInstance().addWindow(_mainMenu,"String_Node_Str");
  GUIManager.getInstance().addWindow(_configMenu,"String_Node_Str");
  GUIManager.getInstance().addWindow(_selectWorldMenu,"String_Node_Str");
}
Program: 1209
Project: 1209
Buggy source:
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  UIButton singlePlayerButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton configButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton exitButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  singlePlayerButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      GUIManager.getInstance().setFocusedWindow(_selectWorldMenu);
    }
  }
);
  exitButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  configButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      GUIManager.getInstance().setFocusedWindow(_configMenu);
    }
  }
);
}

Fixed version (ground truth):
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  UIButton singlePlayerButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton configButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton exitButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  singlePlayerButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _selectWorldMenu.fillList();
      GUIManager.getInstance().setFocusedWindow(_selectWorldMenu);
    }
  }
);
  exitButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  configButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      GUIManager.getInstance().setFocusedWindow(_configMenu);
    }
  }
);
}
Program: 1210
Project: 1210
Buggy source:
public void clearData(){
  _selectedItemIndex=-1;
  _items.get(_selectedItemIndex).setSelected(false);
}

Fixed version (ground truth):
public void clearData(){
  if (_selectedItemIndex < 0) {
    return;
  }
  _items.get(_selectedItemIndex).setSelected(false);
  _selectedItemIndex=-1;
}
Program: 1211
Project: 1211
Buggy source:
public void removeAll(){
  for (int i=(_items.size() - 1); i >= 0; i--) {
    removeDisplayElement(_items.get(i));
    _items.remove(i);
  }
}

Fixed version (ground truth):
public void removeAll(){
  clearData();
  for (int i=(_items.size() - 1); i >= 0; i--) {
    removeDisplayElement(_items.get(i));
    _items.remove(i);
  }
}
Program: 1213
Project: 1213
Buggy source:
public void init(){
  _gameInstance=Terasology.getInstance();
  setupMainMenu();
  setupConfigMenu();
  GUIManager.getInstance().addWindow(_mainMenu);
  GUIManager.getInstance().addWindow(_configMenu);
  GUIManager.getInstance().addWindow(_selectWorldMenu);
}

Fixed version (ground truth):
public void init(){
  _gameInstance=Terasology.getInstance();
  setupMainMenu();
  setupSelectWorldMenu();
  setupConfigMenu();
  _mainMenu.name="String_Node_Str";
  _configMenu.name="String_Node_Str";
  _selectWorldMenu.name="String_Node_Str";
  GUIManager.getInstance().addWindow(_mainMenu,"String_Node_Str");
  GUIManager.getInstance().addWindow(_configMenu,"String_Node_Str");
  GUIManager.getInstance().addWindow(_selectWorldMenu,"String_Node_Str");
}
Program: 1215
Project: 1215
Buggy source:
public void activate(){
  Mouse.setGrabbed(false);
  playBackgroundMusic();
  if (Config.getInstance().getActiveViewingDistanceId() == 3)   _configMenu.getViewingDistanceButton().getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 1)   _configMenu.getViewingDistanceButton().getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 2)   _configMenu.getViewingDistanceButton().getLabel().setText("String_Node_Str");
 else   _configMenu.getViewingDistanceButton().getLabel().setText("String_Node_Str");
  if (Config.getInstance().getGraphicsQuality() == 1)   _configMenu.getGraphicsQualityButton().getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getGraphicsQuality() == 2)   _configMenu.getGraphicsQualityButton().getLabel().setText("String_Node_Str");
 else   _configMenu.getGraphicsQualityButton().getLabel().setText("String_Node_Str");
  _configMenu.getFOVButton().getLabel().setText("String_Node_Str" + (int)Config.getInstance().getFov());
}

Fixed version (ground truth):
public void activate(){
  Mouse.setGrabbed(false);
  playBackgroundMusic();
  UIButton graphicsQualityButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  UIButton FOVButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  UIButton viewingDistanceButton=(UIButton)_configMenu.getElementById("String_Node_Str");
  if (Config.getInstance().getActiveViewingDistanceId() == 3)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 1)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getActiveViewingDistanceId() == 2)   viewingDistanceButton.getLabel().setText("String_Node_Str");
 else   viewingDistanceButton.getLabel().setText("String_Node_Str");
  if (Config.getInstance().getGraphicsQuality() == 1)   graphicsQualityButton.getLabel().setText("String_Node_Str");
 else   if (Config.getInstance().getGraphicsQuality() == 2)   graphicsQualityButton.getLabel().setText("String_Node_Str");
 else   graphicsQualityButton.getLabel().setText("String_Node_Str");
  FOVButton.getLabel().setText("String_Node_Str" + (int)Config.getInstance().getFov());
}
Program: 1216
Project: 1216
Buggy source:
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  _selectWorldMenu=new UISelectWorldMenu();
  _selectWorldMenu.setVisible(false);
  _mainMenu.getSinglePlayerButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _selectWorldMenu.setVisible(true);
    }
  }
);
  _mainMenu.getExitButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  _mainMenu.getConfigButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _configMenu.setVisible(true);
    }
  }
);
  _selectWorldMenu.getGoToBackButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _selectWorldMenu.setVisible(false);
      _mainMenu.setVisible(true);
    }
  }
);
}

Fixed version (ground truth):
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  UIButton singlePlayerButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton configButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  UIButton exitButton=(UIButton)_mainMenu.getElementById("String_Node_Str");
  singlePlayerButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _selectWorldMenu.setVisible(true);
    }
  }
);
  exitButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  configButton.addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _configMenu.setVisible(true);
    }
  }
);
}
Program: 1217
Project: 1217
Buggy source:
public void addWindow(UIDisplayWindow window){
  if (window.isMaximized()) {
    _renderer.addtDisplayElementToPosition(0,window);
  }
 else {
    _renderer.addDisplayElement(window);
  }
}

Fixed version (ground truth):
public void addWindow(UIDisplayWindow window,String windowId){
  if (window.isMaximized()) {
    _renderer.addtDisplayElementToPosition(0,window);
  }
 else {
    _renderer.addDisplayElement(window);
  }
  _windowsById.put(windowId,window);
}
Program: 1218
Project: 1218
Buggy source:
private void checkTopWindow(){
  if (_focusedWindow.isModal() && _focusedWindow.isVisible()) {
    return;
  }
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  int size=_renderer.getDisplayElements().size();
  for (int i=size - 1; i >= 0; i--) {
    UIDisplayWindow window=(UIDisplayWindow)_renderer.getDisplayElements().get(i);
    if (window.isVisible() && window.intersects(mousePos)) {
      if (!window.isMaximized()) {
        _renderer.changeElementDepth(i,size - 1);
      }
      _focusedWindow=window;
      break;
    }
    ;
  }
}

Fixed version (ground truth):
private void checkTopWindow(){
  if (_focusedWindow.isModal() && _focusedWindow.isVisible()) {
    return;
  }
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  int size=_renderer.getDisplayElements().size();
  for (int i=size - 1; i >= 0; i--) {
    UIDisplayWindow window=(UIDisplayWindow)_renderer.getDisplayElements().get(i);
    if (window.isVisible() && window.intersects(mousePos)) {
      setTopWindow(i);
      break;
    }
    ;
  }
}
Program: 1219
Project: 1219
Buggy source:
/** 
 * Process keyboard input - first look for "system" like events, then otherwise pass to the Player object
 */
public void processKeyboardInput(int key){
  for (  UIDisplayElement screen : _renderer.getDisplayElements()) {
    if (screenCanFocus(screen)) {
      screen.processKeyboardInput(key);
    }
  }
}

Fixed version (ground truth):
/** 
 * Process keyboard input - first look for "system" like events, then otherwise pass to the Player object
 */
public void processKeyboardInput(int key){
  for (  UIDisplayElement screen : _renderer.getDisplayElements()) {
    if (screen.isVisible() && !screen.isOverlay()) {
      screen.processKeyboardInput(key);
    }
  }
}
Program: 1220
Project: 1220
Buggy source:
public void removeWindow(UIDisplayWindow window){
  _renderer.removeDisplayElement(window);
}

Fixed version (ground truth):
public void removeWindow(UIDisplayWindow window){
  _renderer.removeDisplayElement(window);
  if (_windowsById.containsValue(window)) {
    for (    String key : _windowsById.keySet()) {
      if (_windowsById.get(key).equals(window)) {
        _windowsById.remove(key);
        break;
      }
    }
  }
}
Program: 1222
Project: 1222
Buggy source:
public void clicked(Vector2f mousePos){
  _focused=true;
  if (_inputValue.length() > 0 && _inputText.getTextWidth() > 0) {
    Vector2f absolutePosition=_inputText.calcAbsolutePosition();
    float positionRelativeElement=(absolutePosition.x + _inputText.getTextWidth()) - mousePos.x;
    float averageSymbols=_inputText.getTextWidth() / _inputValue.length();
    int pos=Math.abs((int)(positionRelativeElement / averageSymbols) - _inputValue.length());
    if (pos > (_inputValue.length() - 1)) {
      pos=_inputValue.length() - 1;
    }
 else     if (pos < 0) {
      pos=0;
    }
    _cursorPosition=pos;
    System.out.println(_cursorPosition);
  }
}

Fixed version (ground truth):
public void clicked(Vector2f mousePos){
  _focused=true;
  if (_inputValue.length() > 0 && _inputText.getTextWidth() > 0) {
    Vector2f absolutePosition=_inputText.calcAbsolutePosition();
    float positionRelativeElement=(absolutePosition.x + _inputText.getTextWidth()) - mousePos.x;
    float averageSymbols=_inputText.getTextWidth() / _inputValue.length();
    int pos=Math.abs((int)(positionRelativeElement / averageSymbols) - _inputValue.length());
    if (pos > (_inputValue.length() - 1)) {
      pos=_inputValue.length() - 1;
    }
 else     if (pos < 0) {
      pos=0;
    }
    _cursorPosition=pos;
  }
}
Program: 1223
Project: 1223
Buggy source:
public void update(){
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  if (intersects(mousePos)) {
    for (int i=(_items.size() - 1); i >= 0; i--) {
      UIListItem item=_items.get(i);
      if (item.isVisible()) {
        if (item.intersects(mousePos)) {
          if (_mouseDown) {
            if (_selectedItemIndex >= 0) {
              _items.get(_selectedItemIndex).setSelected(false);
            }
            item.setSelected(true);
            _selectedItem=item;
            _selectedItemIndex=i;
            _mouseDown=false;
          }
        }
      }
    }
  }
 else {
    _mouseUp=false;
    _mouseDown=false;
  }
  super.update();
}

Fixed version (ground truth):
public void update(){
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  if (intersects(mousePos)) {
    boolean itemClicked=false;
    for (int i=(_items.size() - 1); i >= 0; i--) {
      UIListItem item=_items.get(i);
      if (item.isVisible()) {
        if (item.intersects(mousePos)) {
          if (_mouseDown) {
            if (item.isSelected()) {
              break;
            }
            if (_selectedItemIndex >= 0) {
              _items.get(_selectedItemIndex).setSelected(false);
            }
            item.setSelected(true);
            _selectedItem=item;
            _selectedItemIndex=i;
            _mouseDown=false;
            itemClicked=true;
          }
        }
      }
    }
    if (!itemClicked) {
      _mouseUp=false;
      _mouseDown=false;
    }
  }
 else {
    _mouseUp=false;
    _mouseDown=false;
  }
  super.update();
}
Program: 1224
Project: 1224
Buggy source:
public UIListItem(Vector2f size,String text,Object value){
  setSize(size);
  _text=text;
  _value=value;
  _label=new UIText();
  _label.setVisible(true);
  _label.setColor(Color.white);
  _label.setPosition(new Vector2f((getPosition().x + _padding.x),(getPosition().y + _padding.y)));
  _label.setText(_text);
  if (getSize().x < _label.getTextWidth()) {
    setSize(new Vector2f(_label.getTextWidth(),getSize().y));
  }
  addDisplayElement(_label);
}

Fixed version (ground truth):
public UIListItem(Vector2f size,String text,Object value){
  setSize(size);
  _text=text;
  _value=value;
  _label=new UIText();
  _label.setVisible(true);
  _label.setColor(Color.black);
  _label.setPosition(new Vector2f((getPosition().x + _padding.x),(getPosition().y + _padding.y)));
  _label.setText(_text);
  if (getSize().x < _label.getTextWidth()) {
    setSize(new Vector2f(_label.getTextWidth(),getSize().y));
  }
  addDisplayElement(_label);
}
Program: 1225
Project: 1225
Buggy source:
public void setSelected(boolean selected){
  _isSelected=selected;
  if (_isSelected) {
    _label.setColor(Color.orange);
  }
 else {
    _label.setColor(Color.black);
  }
}

Fixed version (ground truth):
public void setSelected(boolean selected){
  _isSelected=selected;
  if (_isSelected) {
    setStyle("String_Node_Str","String_Node_Str");
    _label.setColor(Color.orange);
  }
 else {
    setStyle("String_Node_Str","String_Node_Str");
    _label.setColor(Color.black);
  }
}
Program: 1226
Project: 1226
Buggy source:
public UIScrollBarThumb(Vector2f size,UIScrollBar.ScrollType scrollType){
  setSize(size);
  _scrollType=scrollType;
  _header=new UIGraphicsElement("String_Node_Str");
  _body=new UIGraphicsElement("String_Node_Str");
  _footer=new UIGraphicsElement("String_Node_Str");
  _header.setVisible(true);
  _body.setVisible(true);
  _footer.setVisible(true);
  addDisplayElement(_header);
  addDisplayElement(_body);
  addDisplayElement(_footer);
switch (scrollType) {
case vertical:
    setVerticalOptions();
  break;
case horizontal:
setHorizontalPositions();
break;
}
}

Fixed version (ground truth):
public UIScrollBarThumb(Vector2f size,UIScrollBar.ScrollType scrollType){
  setSize(size);
  _scrollType=scrollType;
  _header=new UIGraphicsElement("String_Node_Str");
  _body=new UIGraphicsElement("String_Node_Str");
  _footer=new UIGraphicsElement("String_Node_Str");
  _header.setVisible(true);
  _body.setVisible(true);
  _footer.setVisible(true);
  addDisplayElement(_header);
  addDisplayElement(_body);
  addDisplayElement(_footer);
switch (scrollType) {
case vertical:
    setVerticalOptions();
  break;
case horizontal:
setHorizontalPositions();
break;
}
_header.getTextureOrigin().set(0f,155f / 512f);
_body.getTextureOrigin().set(7f / 512f,155f / 512f);
_footer.getTextureOrigin().set(0f,155f / 512f);
}
Program: 1227
Project: 1227
Buggy source:
public void setStyle(String property,String value){
  if (_style == null) {
    _style=new UIDisplayContainerStyle(getSize());
    _style.setPosition(getPosition());
    _style.setVisible(true);
    _style.setCroped(false);
    addDisplayElement(_style);
  }
  _style.parseStyle(property,value);
}

Fixed version (ground truth):
public void setStyle(String property,String value){
  if (_style == null) {
    _style=new UIDisplayContainerStyle(getSize());
    _style.setPosition(new Vector2f(0f,0f));
    _style.setVisible(true);
    _style.setCroped(false);
    addFirstDisplayElement(_style);
  }
  _style.parseStyle(property,value);
}
Program: 1228
Project: 1228
Buggy source:
@Override public void initialize(){
  logger.info("String_Node_Str");
  try {
    AL.create();
  }
 catch (  LWJGLException e) {
    logger.info("String_Node_Str" + e.getMessage());
    return;
  }
  AL10.alGetError();
  logger.info("String_Node_Str" + AL10.alGetString(AL10.AL_VERSION) + "String_Node_Str");
  ALCcontext context=ALC10.alcGetCurrentContext();
  ALCdevice device=ALC10.alcGetContextsDevice(context);
  logger.info("String_Node_Str" + AL10.alGetString(AL10.AL_RENDERER) + "String_Node_Str"+ AL10.alGetString(AL10.AL_VENDOR));
  logger.info("String_Node_Str" + ALC10.alcGetString(device,ALC10.ALC_DEVICE_SPECIFIER));
  logger.info("String_Node_Str" + AL10.alGetString(AL10.AL_EXTENSIONS));
  logger.info("String_Node_Str" + ALC10.alcGetString(device,ALC10.ALC_EXTENSIONS));
  IntBuffer buffer=BufferUtils.createIntBuffer(1);
  ALC10.alcGetInteger(device,ALC11.ALC_MONO_SOURCES,buffer);
  logger.info("String_Node_Str" + buffer.get(0));
  buffer.rewind();
  ALC10.alcGetInteger(device,ALC11.ALC_STEREO_SOURCES,buffer);
  logger.info("String_Node_Str" + buffer.get(0));
  buffer.rewind();
  ALC10.alcGetInteger(device,ALC10.ALC_FREQUENCY,buffer);
  logger.info("String_Node_Str" + buffer.get(0));
  buffer.rewind();
  AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
  this._pools.put("String_Node_Str",new BasicSoundPool(30));
  this._pools.put("String_Node_Str",new BasicStreamingSoundPool(2));
  this.loadAssets();
}

Fixed version (ground truth):
@Override public void initialize(){
  logger.info("String_Node_Str");
  try {
    AL.create();
  }
 catch (  LWJGLException e) {
    throw new RuntimeException(e);
  }
  AL10.alGetError();
  logger.info("String_Node_Str" + AL10.alGetString(AL10.AL_VERSION) + "String_Node_Str");
  ALCcontext context=ALC10.alcGetCurrentContext();
  ALCdevice device=ALC10.alcGetContextsDevice(context);
  logger.info("String_Node_Str" + AL10.alGetString(AL10.AL_RENDERER) + "String_Node_Str"+ AL10.alGetString(AL10.AL_VENDOR));
  logger.info("String_Node_Str" + ALC10.alcGetString(device,ALC10.ALC_DEVICE_SPECIFIER));
  logger.info("String_Node_Str" + AL10.alGetString(AL10.AL_EXTENSIONS));
  logger.info("String_Node_Str" + ALC10.alcGetString(device,ALC10.ALC_EXTENSIONS));
  IntBuffer buffer=BufferUtils.createIntBuffer(1);
  ALC10.alcGetInteger(device,ALC11.ALC_MONO_SOURCES,buffer);
  logger.info("String_Node_Str" + buffer.get(0));
  buffer.rewind();
  ALC10.alcGetInteger(device,ALC11.ALC_STEREO_SOURCES,buffer);
  logger.info("String_Node_Str" + buffer.get(0));
  buffer.rewind();
  ALC10.alcGetInteger(device,ALC10.ALC_FREQUENCY,buffer);
  logger.info("String_Node_Str" + buffer.get(0));
  buffer.rewind();
  AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
  this._pools.put("String_Node_Str",new BasicSoundPool(30));
  this._pools.put("String_Node_Str",new BasicStreamingSoundPool(2));
  this.loadAssets();
}
Program: 1229
Project: 1229
Buggy source:
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  _mainMenu.getStartButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().setGameState(Terasology.GAME_STATE.SINGLE_PLAYER);
    }
  }
);
  _mainMenu.getExitButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  _mainMenu.getConfigButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _configMenu.setVisible(true);
    }
  }
);
  _mainMenu.getOptionsButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _selectWorldMenu.setVisible(true);
    }
  }
);
  _selectWorldMenu.getGoToBackButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _selectWorldMenu.setVisible(false);
      _mainMenu.setVisible(true);
    }
  }
);
}

Fixed version (ground truth):
private void setupMainMenu(){
  _mainMenu=new UIMainMenu();
  _mainMenu.setVisible(true);
  _selectWorldMenu=new UISelectWorldMenu();
  _selectWorldMenu.setVisible(false);
  _mainMenu.getStartButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().setGameState(Terasology.GAME_STATE.SINGLE_PLAYER);
    }
  }
);
  _mainMenu.getExitButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      Terasology.getInstance().exit();
    }
  }
);
  _mainMenu.getConfigButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _configMenu.setVisible(true);
    }
  }
);
  _mainMenu.getOptionsButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _mainMenu.setVisible(false);
      _selectWorldMenu.setVisible(true);
    }
  }
);
  _selectWorldMenu.getGoToBackButton().addClickListener(new IClickListener(){
    public void clicked(    UIDisplayElement element){
      _selectWorldMenu.setVisible(false);
      _mainMenu.setVisible(true);
    }
  }
);
}
Program: 1230
Project: 1230
Buggy source:
public void clicked(Vector2f mousePos){
  _focused=true;
}

Fixed version (ground truth):
public void clicked(Vector2f mousePos){
  _focused=true;
  if (_inputValue.length() > 0 && _inputText.getTextWidth() > 0) {
    Vector2f absolutePosition=_inputText.calcAbsolutePosition();
    float positionRelativeElement=(absolutePosition.x + _inputText.getTextWidth()) - mousePos.x;
    float averageSymbols=_inputText.getTextWidth() / _inputValue.length();
    int pos=Math.abs((int)(positionRelativeElement / averageSymbols) - _inputValue.length());
    if (pos > (_inputValue.length() - 1)) {
      pos=_inputValue.length() - 1;
    }
 else     if (pos < 0) {
      pos=0;
    }
    _cursorPosition=pos;
    System.out.println(_cursorPosition);
  }
}
Program: 1231
Project: 1231
Buggy source:
public void update(){
  updateGraphicsElementsPosition();
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  if (intersects(mousePos)) {
    if (_mouseDown) {
      _scrolled=true;
      if (_prevMousePos == -1) {
        if (_scrollType == ScrollType.vertical) {
          _prevMousePos=mousePos.y;
        }
 else {
          _prevMousePos=mousePos.x;
        }
      }
    }
  }
  if (_scrolled) {
    scrolled(_scrollType == ScrollType.vertical ? mousePos.y : mousePos.x);
  }
  if (!_mouseDown || !_scrolled || _mouseUp) {
    _scrolled=false;
    _mouseDown=false;
    _prevMousePos=-1;
    _mouseUp=false;
  }
}

Fixed version (ground truth):
public void update(){
  updateThumb();
  Vector2f mousePos=new Vector2f(Mouse.getX(),Display.getHeight() - Mouse.getY());
  if (intersects(mousePos)) {
    if (_mouseDown) {
      _scrolled=true;
      if (_prevMousePos == -1) {
        if (_scrollType == ScrollType.vertical) {
          _prevMousePos=mousePos.y;
        }
 else {
          _prevMousePos=mousePos.x;
        }
      }
    }
  }
  if (_scrolled) {
    scrolled(_scrollType == ScrollType.vertical ? mousePos.y : mousePos.x);
  }
  if (!_mouseDown || !_scrolled || _mouseUp) {
    _scrolled=false;
    _mouseDown=false;
    _prevMousePos=-1;
    _mouseUp=false;
  }
  super.update();
}