0
Follow
2
View

Set action when an item from combobox is selected [closed]

diexinggui 注册会员
2023-01-25 06:43

I strongly suggest you to go through the API (java doc) of controls you use to have a quick idea of what they are capable of.

You can either listen to the valueProperty or selectedItemProperty or you can set an action.

comboBox.setOnAction(e->{
  String value= comboBox.getValue();
  ... // Do the stuff with value
});

or

comboBox.valueProperty().addListener((obs,old,value)->{
    ... // Do the stuff with value
});

or

comboBox.getSelectionModel().selectedItemProperty().addListener((obs,old,value)->{
    ... // Do the stuff with value
});

About the Author

Question Info

Publish Time
2023-01-25 06:43
Update Time
2023-01-25 06:43