[英]How can I change the color of buttons?
我正在使用vaadin開發我的第一個應用程序,並且無法更改按鈕的顏色(希望將其更改為黑色)。 我正在使用從馴鹿繼承的自定義主題。
我以這種方式嘗試:
buttonSetting = new Button();
buttonSetting.setIcon(new ThemeResource("images/icons/16px/setting.png"));
buttonSetting.addStyleName(Reindeer.BUTTON_SMALL);
buttonSetting.addStyleName(Reindeer.LAYOUT_BLACK);
但不起作用,該怎么辦?
據我所知,Reindeer.LAYOUT_BLACK應該是包含Button的組件的樣式名稱。
public class AdminBar extends CustomComponent {
private final HorizontalLayout layout = new HorizontalLayout();
public AdminBar(Lang lang) {
setCompositionRoot(layout);
setWidth(100, Unit.PERCENTAGE);
layout.setWidth(100, Unit.PERCENTAGE);
setStyleName(Reindeer.LAYOUT_BLACK);
Button button = new Button("I'm a Button");
button.setStyleName(Reindeer.BUTTON_SMALL);
layout.addComponent(button);
}
}
如果您設置HorizontalLayout而不是AdminBar的樣式名稱,則整個布局將為黑色。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.