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

All CheckBox...Cells: Disable CheckBox when not editable without throwing NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx15, jfx16
    • javafx
    • None
    • generic
    • generic

      All CheckBox...Cell implementation should disable their CheckBox, when the cell or a corresponding dependency like the cell container (e.g. ListView) is disabled.

      While doing that, they should permit null for any dependency, so e.g. a null cell container. (see also ListViewCell/TreeCell/TreeTableCell/TableCell)

      Affected classes:
      CheckBoxListCell -> disable handling missing
      CheckBoxTreeCell -> disable handling missing
      CheckBoxTreeTableCell -> disable handling present, but throws NPE as soon as e.g. TreeTableView is null + TreeTableRow is not considered, see JDK-8268295
      CheckBoxTableCell -> disable handling present, but throws NPE as soon as e.g. TableView is null + TableRow is not considered, see JDK-8268295

      ---- SOURCE -----

      import javafx.application.Application;
      import javafx.beans.property.SimpleBooleanProperty;
      import javafx.collections.FXCollections;
      import javafx.scene.Scene;
      import javafx.scene.control.ListCell;
      import javafx.scene.control.ListView;
      import javafx.scene.control.cell.CheckBoxListCell;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      import java.util.Random;

      public class MainListView extends Application {
          @Override
          public void start(Stage primaryStage) {
              ListView<String> listView = new ListView<>();
              listView.setItems(FXCollections.observableArrayList("1", "2", "3", "4", "5", "6"));
              listView.setEditable(false);
              listView.setCellFactory(listV -> {
                  ListCell<String> cell = new CheckBoxListCell<>(s -> new SimpleBooleanProperty(new Random().nextBoolean()));
                  cell.setEditable(false);
                  return cell;
              });

              BorderPane root = new BorderPane(listView);
              Scene scene = new Scene(root);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }

      }

      ---- SOURCE END -----

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: