This discussion is archived
3 Replies Latest reply: Nov 19, 2012 11:36 PM by kapac RSS

problem with choicebox

kapac Newbie
Currently Being Moderated
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 Expert
    Currently Being Moderated
      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 Guru
    Currently Being Moderated
    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 Newbie
    Currently Being Moderated
    Hi
    thank you a lot for the explanations specially the url
    now the warnings have disappeared
    regards

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points