Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GWT-CssResource未运行_Java_Gwt_Cssresource - Fatal编程技术网

Java GWT-CssResource未运行

Java GWT-CssResource未运行,java,gwt,cssresource,Java,Gwt,Cssresource,我对GWT中的CssResource没有什么意见。我想更改AbsolutePanel和label的样式,但它无法运行。当我用setStyleName方法添加style类时,什么都没有发生 在这段代码中,我使用了一个资源: public CustommerView() { MyResource cssResource = GWT.create(MyResource.class); MyCss myCss = cssResource.css(); A

我对GWT中的CssResource没有什么意见。我想更改AbsolutePanel和label的样式,但它无法运行。当我用setStyleName方法添加style类时,什么都没有发生

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

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;    
}
Custommer视图是GWT复合视图。当我想在视图上移动时,我只需在presenter中调用RootPanel.get(“mainArea”).add(view.asWidget)。主区域是div元素


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

缺少
ensureInjected()
调用。

可能重复Yes,U是正确的。cssResource.css().ensureInjected();帮助。非常感谢。