Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.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
GWT2.2根面板CSS错误_Gwt - Fatal编程技术网

GWT2.2根面板CSS错误

GWT2.2根面板CSS错误,gwt,Gwt,嘿,伙计们,我刚开始使用GWT,在Eclipse中运行该项目时遇到以下错误 19:36:16.084[错误][vgwt] 警告: com.google.gwt.user.client.ui.RootPanel 后代将被错误地删除 定位,即不相对于其 父元素,当 “position:static”,即CSS 默认情况下,是有效的。一种可能 修理是打电话 'panel.getElement().getStyle().setPosition(Position.RELATIVE)' java.lang.

嘿,伙计们,我刚开始使用GWT,在Eclipse中运行该项目时遇到以下错误

19:36:16.084[错误][vgwt] 警告: com.google.gwt.user.client.ui.RootPanel 后代将被错误地删除 定位,即不相对于其 父元素,当 “position:static”,即CSS 默认情况下,是有效的。一种可能 修理是打电话 'panel.getElement().getStyle().setPosition(Position.RELATIVE)'

java.lang.IllegalStateException: com.google.gwt.user.client.ui.RootPanel 缺少CSS '位置:{相对,绝对,固定}' 位于com.google.gwt.user.client.ui.AbsolutePanel.verifyPositionNotStatic(AbsolutePanel.java:279) 在com.google.gwt.user.client.ui.AbsolutePanel.add上(AbsolutePanel.java:118) 位于com.ivstel.adaptiv.client.AdaptivGWT.loadLogin(AdaptivGWT.java:29) 位于com.ivstel.adaptiv.client.AdaptivGWT.onModuleLoad(AdaptivGWT.java:21) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机 (方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(未知)处 (来源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知)处 (来源) 位于java.lang.reflect.Method.invoke(未知 (来源) 位于com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396) 位于com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183) 位于com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510) 在com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) 位于java.lang.Thread.run(未知源)

这就是我儿子的样子:

public class AdaptivGWT implements EntryPoint {

private static AdaptivGWT singleton;

        public static AdaptivGWT get() {
                return singleton;
        }

        public void onModuleLoad() {
                singleton = this;
                loadLogin();
        }

        public void loadLogin() {
                RootPanel.get("login").clear();
                RootPanel.get("main").clear();

                LoginGWT login = new LoginGWT();
                RootPanel.get("login").add(login, 10, 10);
        }

        public void loadMain(User user) {
                RootPanel.get("login").clear();

                MainGWT main = new MainGWT();
                RootPanel.get("main").add(main, 10, 10);
        }
}
HTML文件

<!doctype html>
<!-- The DOCTYPE declaration above will set the    -->
<!-- browser's rendering engine into               -->
<!-- "Standards Mode". Replacing this declaration  -->
<!-- with a "Quirks Mode" doctype may lead to some -->
<!-- differences in layout.                        -->

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <link type="text/css" rel="stylesheet" href="AdaptivGWT.css">

    <title>Adaptiv</title>

    <script type="text/javascript" language="javascript" src="adaptivgwt/adaptivgwt.nocache.js"></script>
  </head>

  <body>

    <!-- OPTIONAL: include this if you want history support -->
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

    <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>

    <div id="login"></div>
    <div id="main"></div>

  </body>
</html>

适应
您的web浏览器必须启用JavaScript
以使此应用程序正确显示。

通过
添加方法使用position参数(即10、10)需要将GWT小部件添加到的元素作为子元素,也需要定位元素(即它们必须具有属性:
位置:
)。在您的例子中,div(带有id main和login)没有位置。最好使用
add(main)
。如果您想将元素定位在左/上10像素的位置,请使用css边距或填充(取决于您的用例)


另一方面,不必同时拥有“login”和“main”div,只需使用一个div,或者直接将其添加到主体中,即使用
get()
。这样,您就可以在GWT中拥有完全的控制权,而不是在html文件中拥有部分结构。

我猜这个问题的答案在这里没有显示的部分:您的主html文件,其中包含
main
login
标记的html元素。那么你也可以添加html。非常感谢。删除位置参数修复了它。我将直接向根面板添加一组控件。如何使用x/y参数在根面板中添加组件?我如何指定根面板的位置,或者这是不可能的?