Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

RESET JavaFX Combobox

2909064Apr 8 2015

I have a multi scene JavaFX 2.2 application the code is on gitHub at this linkhttps://github.com/acaicedo/JFX-MultiScreen

When the application loads each scene has a controller and the scene to be displayed is loaded in a HasMap. When you go to Scene1 I have a ComboBox built with SceneBuilder so it has a FXML id cbNav and an onAction event. when I call this code from the ComboBox I get java.lang.IndexOutOfBoundsException but when I call the code below from a Button onAction event no error is produced

  public void setData() {

  cbNav.getItems().clear();

  //cbNav.setValue(null);

  cbNav.getItems().addAll("To 2","To 3","To 4");

  cbNav.setPromptText("New Me:");

    }

     //Initializes the controller class.

    @Override

    public void initialize(URL url, ResourceBundle rb) {

    setData();

    }

  @FXML

  public void goWhere(ActionEvent e) throws Exception{

  if(cbNav.getValue()=="To 2") {

  setData();

  myController.setScreen(ScreensFramework.screen2ID);

  }

Button Code below

    @FXML

    private void goToScreen2(ActionEvent event){

    setData();

    myController.setScreen(ScreensFramework.screen2ID);

    }

So the question is how do I RESET the ComboBox after the ComboBox is selected?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2015
Added on Apr 8 2015
0 comments
899 views