Mustak
Mustak

Reputation: 9

How to get gwt widget default stylename

In gwt how to get a widget's default style(CSS Selector).For example, gwt button has style name "gwt-button" which is referenced in gwt theme css file. How to got that programmatically. Is there any,

DOM.getStyleAttribute();

to accomplish this. GWT experts please help.

Upvotes: 0

Views: 240

Answers (1)

S. Vincent
S. Vincent

Reputation: 111

In your example of button (or any object that is a child of UIObject) can call getStyleName()

UIObject documentation

String com.google.gwt.user.client.ui.UIObject.getStyleName()


Gets all of the object's style names, as a space-separated list. If you wish to retrieve only the primary style name, call getStylePrimaryName().

Now as to why you need this information is the real question. It is my guess that you want to change the styling of an object (add or remove). This would best be done by either of the following methods.

1) Supplying a custom resources file to the object that has your styling

2) creating a class that extends Composite and create a custom UIBinder class with all of your styles within it.

Upvotes: 2

Related Questions