tags:

views:

29

answers:

1

i have following code

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();
                }
            }


         });

    }
}

but i have following errors

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)

please help

+2  A: 

BeforeSelectionEvent should be BeforeSelectionEvent<Integer> so that getItem() returns an Integer instead of an Object.

Object doesn't have an intValue() method, and Integer does.

You should have also seen an unchecked conversion warning in your compile saying something to that effect.

Jason Hall