2010-09-03 8 views
1

j'ai de code suivantGWT mise en œuvre

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


     }); 

    } 
} 

mais j'ai erreurs suivantes

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) 

s'il vous plaît aident

+0

Ceci est une erreur Java vous indiquant qu'il ne peut pas trouver la méthode intValue(), peut-être que vous avez oublié de faire une distribution? – pathed

Répondre

4

BeforeSelectionEvent devrait être BeforeSelectionEvent<Integer> pour que getItem() retourne un Integer au lieu d'un Object.

Object ne possède pas une méthode intValue() et Integer fait.

Vous devriez également avoir vu un avertissement de conversion non contrôlé dans votre compilation disant quelque chose à cet effet.