2012-10-05 15 views
5

मेरे पास एक टेबलव्यू है और पंक्तियों के डिफ़ॉल्ट रंगों को बदलना चाहता हूं यदि मैं ...
1. ... एक पंक्ति से ऊपर होवर करें।
2. ... एक पंक्ति का चयन किया।
टेबल व्यू की पंक्तियों के रंगों को कैसे बदला जाए?

क्या सीएसएस-फाइल में यह सब करने का कोई आसान तरीका है?

सभी मुझे पता चला मामले 1 के लिए, मैं सीएसएस फ़ाइल में

.table-cell:hover { -fx-background-color: green; }

सेट कर सकते हैं। उसके साथ सेल का रंग बदलता है लेकिन पूरी पंक्ति का रंग नहीं।

.table-view .row-selection:hover{ -fx-background-color: lightgreen; } और मैंने कोशिश की कई अन्य संयोजन काम नहीं कर रहे हैं।

उत्तर

16
/* Selected row */ 
.table-view:focused .table-row-cell:filled:focused:selected { 
    -fx-background-color: brown; 
    -fx-background-insets: 0, 1, 2; 
    -fx-background: -fx-accent; 
    -fx-text-fill: -fx-selection-bar-text; 
} 

/* Selected row when table not focused */ 
.table-row-cell:filled:focused:selected { 
    -fx-background-color: red; 
    -fx-background-insets: 0, 1, 2; 
    -fx-background: -fx-accent; 
    -fx-text-fill: -fx-selection-bar-text; 
} 

/* Row hovered */ 
.table-view:row-selection .table-row-cell:filled:hover { 
    -fx-background-color: green; 
    -fx-background-insets: 0, 0 0 1 0; 
    -fx-text-fill: -fx-text-inner-color; 
} 

/* Selected row hovered */ 
.table-view:focused .table-row-cell:filled:focused:selected:hover { 
    -fx-background: -fx-accent; 
    -fx-background-color: yellow; 
    -fx-background-insets: 0, 1, 2; 
    -fx-text-fill: -fx-selection-bar-text; 
} 

/* Selected row hovered when table not focused */ 
.table-view:row-selection .table-row-cell:filled:focused:hover { 
    -fx-background-color: blue; 
    -fx-background-insets: 0, 0 0 1 0, 1 1 2 1, 2 2 3 2, 3 3 4 3; 
    -fx-text-fill: -fx-text-inner-color; 
} 
+0

+1, हालांकि मैं पहले खंड से 'केंद्रित' को हटा दूंगा, इसलिए यह पढ़ता है: '.table-view: केंद्रित .table-row-cell: filled: चयनित'। इसका कारण यह है कि जब एकाधिक चयन सक्षम होता है तो यह केवल पहली चयनित पंक्ति को प्रभावित करता है। –

संबंधित मुद्दे