2017-07-03 48 views
0

我想在樣式表中爲JavaFX場景做一些CSS樣式。 它將在打開場景時加載,並針對場景中的所有「基本」元素。JavaFX如何設計複選框的按鈕部分?

我的問題是,我似乎無法找到正確的代碼組合,更改背景顏色,在標準的JavaFX複選框中的按鈕。

這就是我現在:

.check-box:selected{ 
    -fx-background-color: #00FF00; 
} 

我已經嘗試了以上的一些變種,像

.check-box .button{ 
    -fx-fill: #00FF00; 
    -fx-background-color: #00FF00; 
} 

和其他人,但沒有成功。

所以一般來說,我如何訪問複選框中的按鈕?

預先感謝您:-)

回答

0

CheckBox的部分應用-fx-background-color到是.box.box > .mark如果你想改變的標誌顏色:

.check-box:selected > .box { 
    /* background color for selected checkbox */ 
    -fx-background-color: lime; 
} 

.check-box > .box { 
    /* background color of unselected checkbox */ 
    -fx-background-color: red; 
} 

.check-box:selected > .box > .mark, 
.check-box:indeterminate > .box > .mark { 
    /* modify mark color */ 
    -fx-background-color: blue; 
} 
+0

完美 - 謝謝你: - ) – Danfjo