Style objects

If you want to change the display of a particular component dynamically, you can set an assignable property on the style object returned by the getStyle() method.

You can set the assignable properties of the root element of a web component directly on the style object returned by the getStyle method. A property that is assigned using this style object overrides the user agent and author rules.

The following example shows how you can override the combobox style dynamically:

. . .
IlxWComboBox myCombo = new IlxWComboBox(myComboBoxModel);
. . .
InputStream stream = application.getResourceAsStream("/myresources/mycombo.css");
Reader reader = new InputStreamReader(stream);
IlxWCSSRuleset ruleset = new IlxWCSSRuleset(reader);
myCombo.setAuthorRules(ruleset);
. . .

In this example, the getStyle method sets the cell padding to 1 in rendering the table. It replaces the value of 10 specified in the mycombo.css file.

When assigning a property to the style object, you must provide the name of the property as a Java™ identifier that is built from the original property name. For example, xxx-yyy is replaced by xxxYyy.

The following example sets the value of the background color of the table element to blue:

myCombo.getStyle().set(“backgroundColor”, “blue”);