need to set multiple styles (setStyleName)

Hi All

I have this button, which is a link, so I do something like


....
myButton.setStyleName(BaseTheme.BUTTON_LINK);

No I also want to add an other class, but if I use ‘setStyleName’ again it overrides the ‘BUTTON_LINK’ class

Any suggestions how to do this ?

thnx a lot
Luca

Try using addStyleName.

thnx, thats it

One last question. Is it also possible to add a style to a grid block, because the link doesn’t cover the whole block!?

I’m not sure what you mean, maybe a screenshot and/or a code-example could clarify?

(as a far-out guess: try setting the Button as 100% wide)

100% doesn’t work, because the div around it has the same size as the button (which depends on the Caption), this div might be from the grid!?


<div style="float: left; margin-left: 0px;">
     <div tabindex="0" class="v-button v-button-link link v-button-odd odd v-button-xxxxx xxxxx" role="button">
             <span class="v-button-wrap">
                          <span class="v-button-caption">BUI</span>
            </span>
     </div>
</div>

the class ‘xxxxx’ has a “width: 100%!important”, however the out-div is small too

UPDATE: problem solved when I did a ‘setSizeFull()’ on the link!

In Java Code, You can use addStyleName(xxx) to add style name one by one,
I beleive you should use this method, because it is more elegant.

But in the Vaadin Editor, there is only one [Style Name]
property to set, we can not call the addStyleName() method in the Editor.

The API doc of method [com.vaadin.ui.AbstractComponent.setStyleName(String)]
says:

https://vaadin.com/api/com/vaadin/ui/Component.html#setStyleName(java.lang.String)

Multiple styles can be specified as a space-separated list of style names And the source code of this method is:

        .....
        StringTokenizer tokenizer = new StringTokenizer(style, " ");
        while (tokenizer.hasMoreTokens()) {
            styles.add(tokenizer.nextToken());
        }

So you can use “styleName1 styleName2 styleName3” in the Vaadin Editor