1

http://www.tutorialspoint.com/gwt/gwt_style_with_css.htmの初心者向けチュートリアルに従っています。HelloWorld.html ファイルのコードは次のとおりです。

<html>
<head>
<title>Hello World</title>
   <link rel="stylesheet" href="HelloWorld.css"/>
   <script language="javascript" src="helloworld/helloworld.nocache.js">
   </script>
</head>
<body>

<div id="mytext"><h1>Hello, World!</h1></div>
<div id="gwtGreenButton"></div>
<div id="gwtRedButton"></div>

</body>
</html>

HelloWorld.java (EntryPoint の拡張) には、次のものがあります。

RootPanel.get("gwtGreenButton").add(Btn1);
RootPanel.get("gwtRedButton").add(Btn2);

2 行: RootPanel.get() は常に null になります。何が起こるかわかりません。何を確認すればよいですか?(このサイトにはコメント/ディスカッション セクションがないのが残念です)

ありがとう。

4

1 に答える 1

0

ドキュメントは言う

RootPanel.get(java.lang.String id)

特定のブラウザ要素に関連付けられたルート パネルを取得します。

DOM.getElementById(java.lang.String)

ドキュメント全体で指定された一意の ID に関連付けられた要素を取得します。

試してみてください

com.google.gwt.user.client.DOM.getElementById("gwtGreenButton");

com.google.gwt.user.client.DOM.getElementById("gwtRedButton");
于 2013-04-21T13:28:28.153 に答える