then both of the CSS style rules below will be applied:
// This rule is based on the primary style name and is always active. .gwt-TextBox { font-size: 12pt; } // This rule is based on a dependent style name that is only active // when the widget has called addStyleName(getStylePrimaryName() + // "-readonly"). .gwt-TextBox-readonly { background-color: lightgrey; border: none; }
Dependent style names are powerful because they are automatically updated whenever the primary style name changes. Continuing with the example above, if the primary style name changed due to the following call:
setStylePrimaryName("my-TextThingy");
then the object would be re-associated with following style rules, removing those that were shown above.
.my-TextThingy { font-size: 20pt; } .my-TextThingy-readonly { background-color: red; border: 2px solid yellow; }
Secondary style names that are not dependent style names are not automatically updated when the primary style name changes.
@param style the secondary style name to be added @see UIObject @see #removeStyleName(String)Label label = new Label("This text has style"); label.addStyleName("mystyle");
Each style name will occur in two versions: one as specified and one that is prefixed wil the style name of the component. For example, if you have a {@code Button} component and give it "{@code mystyle}" style, the component will have both " {@code mystyle}" and " {@code v-button-mystyle}" styles. You could then style the component either with:
.mystyle {font-style: italic;}
or
.v-button-mystyle {font-style: italic;}
This method will trigger a {@link com.vaadin.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
@param style the new style to be added to the component @see #getStyleName() @see #setStyleName(String) @see #removeStyleName(String)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|