I am looking for to remove the background of a checkbox because it takes space in a TableCell
and it causes that the CheckBox
is not centered.
As you can see if the background is marked red, it exceeds the checkbox and takes space.
Here is a minimal code you can verify it and the screenshoot:
Controller:
public class Controller implements Initializable {
@FXML
private TableColumn<Object,String> one;
@FXML
private TableView<Object> table;
@Override
public void initialize(URL location, ResourceBundle resources) {
one.setCellFactory(cell -> new CheckBoxTableCell<Object, String>(){
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if(empty){
return;
}
CheckBox graphic = (CheckBox) getGraphic();
graphic.setStyle("-fx-background-color: red");
}
});
table.getItems().add(new Object());
}
}
I would like to eliminate the red part so only keeping the box itself.
I tried to reset the padding for it but it doesn't work. Can you help me?
Note: I won't accept setPadding(new Insets(0,-x,-y,0)
so setting negative values to it to compensate the "error" only in that case if you can explain it why it is the only solution.
Aucun commentaire:
Enregistrer un commentaire