【发布时间】:2015-02-21 15:06:55
【问题描述】:
我在应用程序类中有这段代码
scene.getStylesheets().add(getClass().getResource(CONSTANTS.DESIGN_CSS.directory).toExternalForm());
还有这个 CSS 文件
@CHARSET "UTF-8";
#mainList .list-cell {
-fx-background-color: null;
-fx-font-size: 24px;
-fx-text-fill: linear-gradient( from 0.0% 0.0% to 0.0% 50.0%, reflect, rgba(255,0,0,0.28) 0.0, rgba(102,243,255,0.58) 50.0, rgba(179,179,179,0.45) 70.0, rgba(179,179,179,0.45) 100.0);
}
#mainList .list-cell:hover {
-fx-text-fill:linear-gradient( from 0.0% 0.0% to 100.0% 100.0%, reflect, rgb(255,255,255) 0.0, rgb(255,255,77) 100.0);
}
#stoperButton .button {
-fx-background-color: linear-gradient( from 50.0% 100.0% to 100.0% 100.0%, rgb(0,0,0) 0.0, rgb(255,255,255) 100.0);
}
#stoperButton .button:hover {
-fx-background-color: #9ACD32;
}
在第一个加载的控制器中,我可以轻松做到这一点,并且它可以工作:
listView.setId("mainList");
但这(在不同的控制器中)没有错误但没有效果:
buttSTOP.setId("stoperButton");
和改变场景的根有关系吗?
【问题讨论】: