public void applyTo(javafx.scene.layout.TilePane x) {
   super.applyTo(x);
   int set = __set;
   while (set != 0) {
     int i = Integer.numberOfTrailingZeros(set);
     set &= ~(1 << i);
     switch (i) {
       case 0:
         x.setAlignment(this.alignment);
         break;
       case 1:
         x.setHgap(this.hgap);
         break;
       case 2:
         x.setOrientation(this.orientation);
         break;
       case 3:
         x.setPrefColumns(this.prefColumns);
         break;
       case 4:
         x.setPrefRows(this.prefRows);
         break;
       case 5:
         x.setPrefTileHeight(this.prefTileHeight);
         break;
       case 6:
         x.setPrefTileWidth(this.prefTileWidth);
         break;
       case 7:
         x.setTileAlignment(this.tileAlignment);
         break;
       case 8:
         x.setVgap(this.vgap);
         break;
     }
   }
 }
  @FXML
  public void handleOk() {
    String tituloAux = titulo.getText().replaceAll(" ", "+").toLowerCase();
    String toJson = readUrl(BASE + tituloAux + "&type=series" + "&r=json");
    resultados.getChildren().clear();
    try {
      JSONObject busqueda = new JSONObject(toJson);
      if (busqueda.getString("Response").equals("True")) {
        JSONArray res = busqueda.getJSONArray("Search");
        resultados.setPrefRows(res.length());
        for (int i = 0; i < res.length(); i++) {
          JSONObject resActual = new JSONObject(res.get(i).toString());
          HBox resultadoActual = new HBox(50);
          resultadoActual.setMaxWidth(Double.MAX_VALUE);
          resultadoActual.setAlignment(Pos.CENTER_LEFT);
          ImageView posterActual = new ImageView();

          try {
            Image image = new Image(resActual.getString("Poster"));
            posterActual.setImage(image);
            posterActual.setFitHeight(240);
            posterActual.setFitWidth(180);
            posterActual.setPreserveRatio(false);
            resultadoActual.getChildren().add(posterActual);
          } catch (IllegalArgumentException e) {
            //                        System.out.println("Bad url");
            Image image =
                new Image(MainApp.class.getResource("resources/no-image.png").toExternalForm());
            posterActual.setImage(image);
            posterActual.setFitHeight(240);
            posterActual.setFitWidth(180);
            posterActual.setPreserveRatio(false);
            resultadoActual.getChildren().add(posterActual);
          }

          String details;
          String nomSerie = new String(resActual.getString("Title").getBytes(), "UTF-8");
          String anoSerie = new String(resActual.getString("Year").getBytes(), "UTF-8");
          if (nomSerie.length() > 15) {
            details = "%-12.12s...\t\t Año: %-10s";
          } else {
            details = "%-12s\t\t Año: %-10s";
          }
          details = String.format(details, nomSerie, anoSerie);
          Label elemento = new Label(details);
          elemento.setMaxWidth(Double.MAX_VALUE);
          elemento.setMaxHeight(Double.MAX_VALUE);
          resultadoActual.getChildren().add(elemento);

          posterActual.setId(resActual.getString("imdbID"));
          posterActual.setOnMouseClicked(
              new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                  ImageView clickedButton = (ImageView) event.getSource();
                  Stage stage = (Stage) clickedButton.getScene().getWindow();
                  Task task =
                      new Task() {
                        @Override
                        protected Object call() throws Exception {
                          mainController.mainApp.scene.setCursor(Cursor.WAIT);
                          Serie toAdd = new Serie(clickedButton.getId());
                          boolean possible = true;
                          for (Serie serie : mainController.getSeries()) {
                            if (serie.equals(toAdd)) possible = false;
                          }
                          if (possible) mainController.getSeries().add(toAdd);

                          try {
                            mainController.populateImagenes();
                            mainController.showDetallesMes(mainController.getMesActual());
                          } catch (Exception e) {
                            e.printStackTrace();
                          } finally {
                            mainController.mainApp.scene.setCursor(Cursor.DEFAULT);

                            return mainController.getSeries();
                          }
                        }
                      };
                  Thread th = new Thread(task);
                  th.setDaemon(true);
                  th.start();
                  stage.close();
                }
              });
          resultados.getChildren().add(resultadoActual);
        }
      } else {
        resultados.getChildren().add(new Label("La busqueda no obtuvo resultados"));
      }
    } catch (JSONException e) {
      e.printStackTrace();
    } catch (UnsupportedEncodingException ex) {
      Logger.getLogger(NewSerieController.class.getName()).log(Level.SEVERE, null, ex);
    }
  }