rowFactory
は、行を生成し、行のスタイルクラスまたは行に添付された擬似クラスのいずれかを操作するテーブルで使用できます。次に、外部スタイルシートを使用してスタイルを適用します。
PseudoClass foo = PseudoClass.getPseudoClass("foo");
table.setRowFactory(tv -> {
TableRow<MyDataType> row = new TableRow<>();
row.itemProperty().addListener((obs, oldItem, newItem) -> {
if (/* some condition on newItem */) {
row.pseudoClassStateChanged(foo, true);
} else {
row.pseudoClassStateChanged(foo, false);
}
});
return row ;
});
、その後、私が探していたが、まだ私には非常に便利ではなかった、まさに
.table-row-cell {
/* your regular style settings here */
}
.table-row-cell:foo {
/* your specific style for when foo is set here */
}
。セルファクトリーのように、一度に1つのセルではなく、行全体を動的にスタイリングする行に沿って何かを探していました。より明確にするために私の質問を編集します。 –
それは私が探していたものです。どうもありがとうございました。 –
@MichaelPickett関連する質問はhttp://stackoverflow.com/questions/20350099/programmatically-change-the-tableview-row-appearance/20409924#20409924をご覧ください。 –