GWT实现

GWT实现,gwt,Gwt,我有以下代码 package org.david.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.logical.shared.BeforeSelectionEvent; import com.google.gwt.event.logical.shared.BeforeSelectionHandler; import com.google.gwt.event.logical.sha

我有以下代码

package org.david.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.logical.shared.BeforeSelectionEvent;
import com.google.gwt.event.logical.shared.BeforeSelectionHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.TabBar;
public class TabBar1  implements EntryPoint{
    @Override
    public void onModuleLoad(){
        TabBar bar=new TabBar();
        bar.addTab("foo");
        bar.addTab("bar");
        bar.addTab("baz");
         bar.addSelectionHandler(new SelectionHandler(){

             public void onSelection(SelectionEvent event){
                 //let user know what you just did
                 Window.alert("you clicked tab"+event.getSelectedItem());
             }

         });
        // Just for fun, let's disallow selection of 'bar'.
         bar.addBeforeSelectionHandler(new BeforeSelectionHandler() {
          public void onBeforeSelection(BeforeSelectionEvent event) {
       if (event.getItem().intValue() == 1) {
          event.cancel();
                }
            }


         });

    }
}
但我有以下错误

ompiling 1 source file to C:\XAMPP\xampp\htdocs\TabBar1\build\web\WEB-INF\classes
C:\XAMPP\xampp\htdocs\TabBar1\src\java\org\david\client\TabBar1.java:28: cannot find symbol
symbol  : method intValue()
location: class java.lang.Object
       if (event.getItem().intValue() == 1) {
Note: C:\XAMPP\xampp\htdocs\TabBar1\src\java\org\david\client\TabBar1.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
C:\XAMPP\xampp\htdocs\TabBar1\nbproject\build-impl.xml:518: The following error occurred while executing this line:
C:\XAMPP\xampp\htdocs\TabBar1\nbproject\build-impl.xml:248: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

请帮助

BeforeSelectionEvent
应该是
BeforeSelectionEvent
,以便
getItem()
返回一个
整数
,而不是
对象

Object
没有
intValue()
方法,而
Integer


您还应该在编译中看到一个未经检查的转换警告,说明了这一点。

BeforeSelectionEvent
应该是
BeforeSelectionEvent
,以便
getItem()
返回一个
整数,而不是
对象

Object
没有
intValue()
方法,而
Integer


您还应该在编译中看到一个未经检查的转换警告,说明了这一点。

这是一个Java错误,告诉您找不到方法intValue(),可能您忘记执行强制转换?这是一个Java错误,告诉您找不到方法intValue(),可能您忘记执行强制转换?