Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8120381

JavaFX 8 TableView custom cells losses CSS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • 8
    • None
    • javafx
    • Java 8 Build 80

    Description

      When using a table view the first rendering of a customized table cell seems to be ok, but once we start scrolling up and down styling seems to be loosing:
      /*
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      package mx.gob.scjn.iusjfx.presentacion.utils;

      import java.util.List;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javafx.scene.control.TableCell;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.Tooltip;
      import javafx.util.Callback;
      import mx.gob.scjn.ius_common.TO.TesisTO;

      /**
       *
       * @author charly
       */
      public class TesisTC implements Callback<TableColumn, TableCell> {

          public List<TesisTO> tesisActuales = null;
          private static double alto;

          @Override
          public TableCell call(final TableColumn param) {
              final TableCell cell = new TableCell() {
                  
                  @Override
                  public void updateItem(Object item, boolean empty) {
                      super.updateItem(item, empty);
                      if (getIndex() < tesisActuales.size() && getIndex()>=0) {
                          final TesisTO tesis = tesisActuales.get(getIndex());
                          setText((String) item);
                          if (item == null) {
                              return;
                          }
                          final int largo = getText().length() > 200 ? 200 : getText().length();
                          //if (getTooltip() == null || getTooltip().getText().length() != largo) {
                          setTooltip(new Tooltip(getText().substring(0, largo)));
                          getTooltip().setMaxWidth(200);
                          getTooltip().setPrefWidth(200);
      // getTooltip().setMaxHeight(200);
      // getTooltip().setPrefHeight(200);
                          getTooltip().setStyle("-fx-wrap-text: true;");
                          //}
                          if (tesis.getTa_tj() == 1) {
                              getStyleClass().add("jurisTabla");
                          } else {
                              getStyleClass().add("taTabla");
                          }
                          if (alto == 0) {
                              alto = PresentacionConstantes.MIN_ALTO_TABLAS;
                          }
                          this.setHeight(alto);
                          this.setMinHeight(alto);
                          this.setMaxHeight(alto);
                          this.setPrefHeight(alto);
                      }
                  }
              };
              return cell;
          }

          public void setTesisActuales(List<TesisTO> value) {
              tesisActuales = value;
          }

          public void setAlto(double value) {
              alto = value;
          }

          public double getAlto() {
              return alto;
          }
      }

      On the CSS:

      .jurisTabla{
          -fx-font-weight: bold;
          -fx-wrap-text: true;
      }
      .taTabla{
          -fx-font-weight: normal;
          -fx-wrap-text: true;
      }

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            csaenzjfx Carlos de Luna Saenz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: