Program: 77831
Project: 77831
Buggy source:
/** 
 * creats image buttons for green screen image and marks chousen one
 */
private void createGreenscreenButton(){
  FileInputStream fips=null;
  try {
    greengrid=new GridPane();
    greengrid.prefWidth(Screen.getPrimary().getBounds().getWidth());
    filterscrollplanel=new ScrollPane();
    greengrid.setStyle("String_Node_Str");
    filterscrollplanel.setStyle("String_Node_Str");
    filterscrollplanel.setFitToWidth(true);
    filterscrollplanel.setFitToHeight(false);
    filterscrollplanel.prefWidth(Screen.getPrimary().getBounds().getWidth());
    greengrid.getColumnConstraints().add(0,new ColumnConstraints());
    greengrid.getRowConstraints().add(0,new RowConstraints());
    greengrid.getColumnConstraints().add(1,new ColumnConstraints());
    greengrid.getRowConstraints().add(1,new RowConstraints());
    greengrid.getColumnConstraints().add(2,new ColumnConstraints());
    greengrid.getRowConstraints().add(2,new RowConstraints());
    greengrid.getColumnConstraints().add(3,new ColumnConstraints());
    greengrid.getRowConstraints().add(3,new RowConstraints());
    greengrid.getColumnConstraints().add(4,new ColumnConstraints());
    greengrid.getRowConstraints().add(4,new RowConstraints());
    greengrid.getRowConstraints().add(5,new RowConstraints());
    greengrid.getColumnConstraints().get(0).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(0).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(1).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(1).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(2).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(2).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(3).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(3).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(4).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(4).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getRowConstraints().get(5).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    int columcount=0;
    int rowcount=0;
    List<Background> greenList=profileservice.getAllBackgroundOfProfile();
    shootingService.addUserDefinedBackgrounds(greenList);
    for (    Background backround : greenList) {
      if (columcount == 5) {
        rowcount++;
        columcount=0;
        if (rowcount >= 6) {
          greengrid.getRowConstraints().add(rowcount,new RowConstraints());
          greengrid.getRowConstraints().get(rowcount).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
        }
      }
      ImageView iv=new ImageView();
      iv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
      iv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
      iv.setStyle("String_Node_Str");
      fips=new FileInputStream(backround.getPath());
      iv.setImage(new javafx.scene.image.Image(fips,iv.getFitHeight(),iv.getFitWidth(),true,true));
      fips.close();
      if (profile.getPairCameraPositions().get(index).getBackground() != null) {
        if (backround.getId() == profile.getPairCameraPositions().get(index).getBackground().getId()) {
          activiv=iv;
          activiv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
          activiv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
        }
      }
      iv.setOnMouseClicked((      MouseEvent mouseEvent) -> {
        if (activiv != null) {
          activiv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
          activiv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
        }
        activiv=iv;
        iv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
        iv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
        profile.getPairCameraPositions().get(index).setBackground(backround);
      }
);
      greengrid.add(iv,columcount,rowcount);
      columcount++;
    }
    greengrid.setVisible(true);
    filterscrollplanel.setVisible(true);
    filterscrollplanel.setContent(greengrid);
    root.add(filterscrollplanel,0,1);
  }
 catch (  ServiceException|IOException e) {
    LOGGER.error("String_Node_Str",e);
  }
 finally {
    if (fips != null) {
      try {
        fips.close();
      }
 catch (      IOException e) {
        LOGGER.debug("String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * creats image buttons for green screen image and marks chousen one
 */
private void createGreenscreenButton(){
  FileInputStream fips=null;
  try {
    greengrid=new GridPane();
    greengrid.prefWidth(Screen.getPrimary().getBounds().getWidth());
    filterscrollplanel=new ScrollPane();
    greengrid.setStyle("String_Node_Str");
    filterscrollplanel.setStyle("String_Node_Str");
    filterscrollplanel.setFitToWidth(true);
    filterscrollplanel.setFitToHeight(false);
    filterscrollplanel.prefWidth(Screen.getPrimary().getBounds().getWidth());
    greengrid.getColumnConstraints().add(0,new ColumnConstraints());
    greengrid.getRowConstraints().add(0,new RowConstraints());
    greengrid.getColumnConstraints().add(1,new ColumnConstraints());
    greengrid.getRowConstraints().add(1,new RowConstraints());
    greengrid.getColumnConstraints().add(2,new ColumnConstraints());
    greengrid.getRowConstraints().add(2,new RowConstraints());
    greengrid.getColumnConstraints().add(3,new ColumnConstraints());
    greengrid.getRowConstraints().add(3,new RowConstraints());
    greengrid.getColumnConstraints().add(4,new ColumnConstraints());
    greengrid.getRowConstraints().add(4,new RowConstraints());
    greengrid.getRowConstraints().add(5,new RowConstraints());
    greengrid.getColumnConstraints().get(0).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(0).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(1).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(1).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(2).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(2).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(3).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(3).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getColumnConstraints().get(4).setPrefWidth(Screen.getPrimary().getBounds().getWidth() / 4);
    greengrid.getRowConstraints().get(4).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    greengrid.getRowConstraints().get(5).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
    int columcount=0;
    int rowcount=0;
    List<Background> greenList=profileservice.getAllBackgroundOfProfile();
    shootingService.addUserDefinedBackgrounds(greenList);
    for (    Background backround : greenList) {
      if (columcount == 5) {
        rowcount++;
        columcount=0;
        if (rowcount >= 6) {
          greengrid.getRowConstraints().add(rowcount,new RowConstraints());
          greengrid.getRowConstraints().get(rowcount).setPrefHeight(Screen.getPrimary().getBounds().getWidth() / 6);
        }
      }
      ImageView iv=new ImageView();
      iv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
      iv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
      iv.setStyle("String_Node_Str");
      fips=new FileInputStream(backround.getPath());
      iv.setImage(new javafx.scene.image.Image(fips,iv.getFitHeight(),iv.getFitWidth(),true,true));
      fips.close();
      if (profileservice.getActiveProfile().getPairCameraPositions().get(index).getBackground() != null) {
        if (backround.getId() == profileservice.getActiveProfile().getPairCameraPositions().get(index).getBackground().getId()) {
          activiv=iv;
          activiv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
          activiv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
        }
      }
      iv.setOnMouseClicked((      MouseEvent mouseEvent) -> {
        if (activiv != null) {
          activiv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
          activiv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 10);
        }
        activiv=iv;
        iv.setFitHeight(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
        iv.setFitWidth(Screen.getPrimary().getBounds().getWidth() / 5 - 40);
        try {
          profileservice.getActiveProfile().getPairCameraPositions().get(index).setBackground(backround);
        }
 catch (        ServiceException e) {
          LOGGER.error("String_Node_Str",e);
        }
      }
);
      greengrid.add(iv,columcount,rowcount);
      columcount++;
    }
    greengrid.setVisible(true);
    filterscrollplanel.setVisible(true);
    filterscrollplanel.setContent(greengrid);
    root.add(filterscrollplanel,0,1);
  }
 catch (  ServiceException|IOException e) {
    LOGGER.error("String_Node_Str",e);
  }
 finally {
    if (fips != null) {
      try {
        fips.close();
      }
 catch (      IOException e) {
        LOGGER.debug("String_Node_Str",e);
      }
    }
  }
}