2015-02-23 90 views
0

我试图改变combbox背景颜色和文本颜色,并使用下面的样式了JavaFx组合框下拉列表设计问题

.root 
{ 
    //-back:#152635; 
    -darker:#272B30; 
    -dark:#3A3F44; 
    -normal:#52575C; // #555 
    -light:#7A8288; // #999 
    -lighter:#999; // #eee 
    -primary:-light; 
    -success:#62c462; 
    -info:#5bc0de; 
    -warning:#f89406; 
    -danger:#ee5f5b; 
    -fore-color:#C8C8C8; 
    -fx-background-color:-darker ; 
    -focused-color:#64c8c8; 
    -border-color:derive(-darker,50%); 
    -fx-text-fill:-fore-color; 
    -fx-font-size: 14px; 
    -fx-font-weight:100; 
    -fx-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 

} 


.combo-box-base { 
    -fx-background-color:-dark; 
    -fx-text-fill:-fore-color; 
    -fx-min-width:150px; } 

.combo-box-base *.arrow-button { 
    -fx-background-color:derive(-dark,-10%); } 

.combo-box-base *.arrow { 
    -fx-background-color:-normal; } 

.combo-box *.list-view { 
    -fx-background-color:-normal; 
    -fx-text-fill:-fore-color; } 

设计看上去在现场制造商,但在我的应用程序,字体和背景颜色好下拉列表不会改变,这对我来说有点儿惊讶。请帮我找出我的CSS有什么问题。

+0

哪里是'-dark','-fore-color'和'-normal'界定? – 2015-02-23 16:35:38

+0

在根节点css中。让我编辑问题并添加根节点 – ZafarYousafi 2015-02-23 16:47:43

回答

1

虽然@James_D解决方案有效,如果你覆盖的背景颜色,你不会看到悬停,填充或选择的伪类。

这会给你定义的造型对他们来说机会:

.combo-box-popup > .list-view { 
    -fx-background-color: -normal; // or define other color to highlight the border 
} 
.combo-box-popup *.list-cell { 
    -fx-background: -normal; 
    -fx-selection-bar: -light; // filled:hover 
    -fx-cell-focus-inner-border: -dark; // filled:selected:hover 
    -fx-text-fill: -fore-color; 
} 
1

您需要的样式应用到列表中的细胞,而不是列表视图:

.combo-box *.list-view .list-cell { 
    -fx-background-color:-normal; 
    -fx-text-fill:-fore-color; }