简体   繁体   中英

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). 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM