Skip to content

When cell selection is enabled in TableView then selection color is different #108

@PavelTurk

Description

@PavelTurk

This is code:

public class JavaFxTest10 extends Application {

    private static record Student (int id, int mark) {};

    private TableView<Student> table = new TableView<>(FXCollections.observableList(
            List.of(new Student(1, 3), new Student(2, 4), new Student(3, 5))));

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

    @Override
    public void start(Stage primaryStage) {
        Application.setUserAgentStylesheet(new Dracula().getUserAgentStylesheet());

        var idColumn = new TableColumn<Student, Integer>("Id");
        idColumn.setCellValueFactory((data) ->  new ReadOnlyObjectWrapper<>(data.getValue().id()));
        var markColumn = new TableColumn<Student, Integer>("Mark");
        markColumn.setCellValueFactory((data) ->  new ReadOnlyObjectWrapper<>(data.getValue().mark()));
        table.getColumns().addAll(idColumn, markColumn);
        table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        table.getSelectionModel().setCellSelectionEnabled(true);

        VBox root = new VBox(new TextField(), table);
        var scene = new Scene(root, 400, 300);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

If you run it with AtlantaFX you will get this result:

Peek 2024-08-24 20-25

If cell selection is disabled then you will get this result:

Peek 2024-08-24 20-31

As you see selection color is different in both cases. However in pure JavaFX selection color is always the same:

Peek 2024-08-24 20-25b

Is this a bug I misunderstand something?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions