Search code examples
vaadinvaadin7

Vaadin 7 check if style name exists


In my Vaadin 7 application I can add a new style name to a component for example via following method:

panel.addStyleName("criteria-menu-active");

But right the next click on this component I need to check if this style was already added to this component and if so - remove it.

So, how to test the component for the presence of a certain style by its name ?


Solution

  • Did you try the following?

    myLayout.addStyleName("custom-style");
    System.out.println("Style = " + myLayout.getStyleName());
    

    Output:

    Style = custom-style