开发者

How can I change the font size of a GWT Label object dynamically?

开发者 https://www.devze.com 2023-03-13 20:55 出处:网络
In a GWT project, I want to be able to do something like this, to set the font size that\'ll be used for an instance of a Label:

In a GWT project, I want to be able to do something like this, to set the font size that'll be used for an instance of a Label:

public class BigLabel extends Label {
    public BigLabel(String s, int i) {
      super(s);
      setFontSize(i); // sets font size in em units
    }
}

But I can't because I can't find any method that does the same job. I can easily use Label.setStyleName, 开发者_如何学Pythonbut if I do that I have to set it to an absolute value stored in the css file. Is there a way to have a font size that's flexible?


private void setFontSize(double ems) {
  getElement().getStyle().setFontSize(ems, Unit.EM);
}
0

精彩评论

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

关注公众号