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, seeJDK-8268295
CheckBoxTableCell -> disable handling present, but throws NPE as soon as e.g. TableView is null + TableRow is not considered, seeJDK-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 -----
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
CheckBoxTableCell -> disable handling present, but throws NPE as soon as e.g. TableView is null + TableRow is not considered, see
---- 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 -----