开发者

GWT: How to set the style of a HTML Element / First Paramter of HTML.setStylePrimaryName?

I have

HTML test = new HTML( "myhtml" 开发者_如何学编程); 

which generates

<div class="gwt-HTML">MyHTML</div>

I want to set the primary style using this:

HTML.setStylePrimaryName(null, "mystyle");

What must be the first Paramter? Null is not working.


The UIObject.setStylePrimaryName static method is for when you have to work with Elements (you'll also note that it's protected, it really is an implementation detail of widgets and other UI objects).

You'd want to use the setStylePrimaryName instance method:

test.setStylePrimaryName("mystyle");

But actually, most of the time, you'd better use addStyleName, to keep the gwt-HTML class name around (or in the case of a TextBox for instance, keep the gwt-TextBox and gwt-TextBox-readonly; if you change the primary name to mystyle, you'll then have mystyle-readonly instead of gwt-TextBox-readonly, it is sometimes desirable, but most of the time it's not):

text.addStyleName("mystyle");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜