3 Replies Latest reply: Nov 20, 2012 1:36 AM by kapac RSS

    problem with choicebox

    kapac
      Hi;
      i got a problem with choicebox with the code according to the oracle choicebox tutorial
       cb=new ChoiceBox(FXCollections.observableArrayList("Claves","Cloche","Bongo1","Bongo2","Block1","Block2")); 
      i have a warning i don't understand
      warning: [unchecked] unchecked call to ChoiceBox(ObservableList<T>) as a member of the raw type ChoiceBox
      cb=new ChoiceBox(FXCollections.observableArrayList("Claves","Cloche","Bongo1","Bongo2","Block1","Block2"));
      where T is a type-variable:
      T extends Object declared in class ChoiceBox
      i don't understand the meaning and the use of the "T" in the class ChoiceBox<T>
        • 1. Re: problem with choicebox
          shakir.gusaroff
            ChoiceBox<String>   cb = new ChoiceBox<String>(FXCollections.observableArrayList("Claves","Cloche","Bongo1","Bongo2","Block1","Block2"));
          i don't understand the meaning and the use of the "T" in the class ChoiceBox<T>
          http://en.wikipedia.org/wiki/Generics_in_Java
          • 2. Re: problem with choicebox
            jsmith
            You are not the only one to be confused by Java's weird generics warnings. Even perfectly good code seems to get that particular warning. You can read up more at StackOverflow: http://stackoverflow.com/questions/1129795/what-is-suppresswarnings-unchecked-in-java

            For the code in your question though you can probably get rid of the unchecked warning rather by declaring:
            ChoiceBox<String> cb;
            Instead of
            ChoiceBox cb;
            • 3. Re: problem with choicebox
              kapac
              Hi
              thank you a lot for the explanations specially the url
              now the warnings have disappeared
              regards