[英]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.