シーン内に選択したセルを強調表示するテーブルビューがあります。 JavaFX CSS referenceによると、細胞上の疑似クラス:selected
があるので、私は次のCSS試してみました::セルに適用されていない疑似クラススタイル
.cell:selected {
-fx-effect: dropshadow(gaussian, 10, .2, 4, 4);
}
をしかし、スタイルがセルに適用されていません。 .cell:hover
を使用すると、期待どおりに動作します。
次は、単純化されたFXMLです:
<Pane fx:controller="Controller">
<children>
<TableView fx:id="table" />
</children>
</Pane>
私はコントローラとしてこれを使用しています:
public class Controller implements Initializable{
@FXML
private TableView<SomeClass> table;
// some other things
@Override
public void initialize(URL url, ResourceBundle bundle) {
Objects.requireNonNull(table, "Table was not injected");
// create columns, initialize other stuff
table.getColumns().clear();
table.getColumns().addAll(/*some columns */);
table.setEditable(false);
table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
}
}
はなぜCSSは、選択したセルに適用されませんか?