-1

我对 GWT 中的 CssResource 没什么问题。我想更改 AbsolutePanel 和标签的样式,但它不运行。当我使用 setStyleName 方法添加样式类时,什么也没有发生。

在这段代码中,我使用了一个资源:

public CustommerView() {
        MyResource cssResource = GWT.create(MyResource.class);
        MyCss myCss = cssResource.css();

        AbsolutePanel basePanel = new AbsolutePanel();

        initWidget(basePanel);
        basePanel.setStyleName(myCss.rootPanel());


        Label label = new Label();
        label.setText("Im label");
        label.setStyleName(myCss.label());
        basePanel.add(label);

    }

这是我扩展 CssResource 的接口:

public interface MyCss extends CssResource {
    /**
     * Method for return command button class name
     * @return command button class name
     */
     public String rootPanel();

     public String label();
}

这是我的 css 文件,它位于文件系统上的 MyCss 接口旁边:

.rootPanel {
   position:absolute !important; 
   top:0px;
   left:0px;
   background-color:yellow !important;
   height: 20px !important;
   width: 18px !important;  
}

.label {
  color:red;    
}

客户视图是 GWT Composite。当我想继续查看时,我只需在演示者中调用 RootPanel.get("mainArea").add(view.asWidget)。mainArea 是 div 元素。

当我在 web inf 的 css 文件中粘贴 css 类时,一切运行正常。有人可以告诉我如何解决这个问题吗?谢谢。

4

1 回答 1

1

ensureInjected()电话不见了。

于 2012-08-26T16:17:53.523 回答