[英]How can I change the color of buttons?
I'm developing my first application in vaadin and I can't to change the color of my button (want them to blacks). 我正在使用vaadin开发我的第一个应用程序,并且无法更改按钮的颜色(希望将其更改为黑色)。 I'm using my custom theme that inherited from Reindeer.
我正在使用从驯鹿继承的自定义主题。
I try in this way: 我以这种方式尝试:
buttonSetting = new Button();
buttonSetting.setIcon(new ThemeResource("images/icons/16px/setting.png"));
buttonSetting.addStyleName(Reindeer.BUTTON_SMALL);
buttonSetting.addStyleName(Reindeer.LAYOUT_BLACK);
but doesn't work, How can I do? 但不起作用,该怎么办?
As far as I can see Reindeer.LAYOUT_BLACK should be the style name of a component containing the Button. 据我所知,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);
}
}
If you set the style name of the HorizontalLayout instead of the AdminBar, the whole layout will be black. 如果您设置HorizontalLayout而不是AdminBar的样式名称,则整个布局将为黑色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.