0
我有可編輯的組合框。什麼事件是從組合框中選擇項目,而不是actionevent?
tf_name.getEditor().setOnKeyReleased(event -> {
tf_name.hide();
String name= tf_name.getEditor().getText().trim();
tf_name.getSelectionModel().clearSelection();
tf_name.getEditor().setText(name);
tf_name.setItems(Customer.getNameCompanyList(name));
int size=Customer.getNameCompanyList(name).size();
if (size>10) {size=10;
if (size==0) size=0;
}
tf_name.setVisibleRowCount(size);
if (size!=0)
tf_name.show();
tf_name.getEditor().end();
/*tv_info1.setItems(Info2.getInfo2NameDog(name));*/});
tf_name.setOnAction( e->{
{
Customer customer=Customer.getCustomer(Customer.find_id_cust_Name(tf_name.getValue()));
tf_phone.setText(customer.getPhone());
cb_cust_district.setValue(customer.getDistrict());
cb_city_type.setValue(customer.getCity_type());
tf_city_name.setText(customer.getCity_name());
tf_street.setText(customer.getStreet());
tf_house.setText(String.valueOf(customer.getHouse()));
tf_housing.setText(customer.getHousing());
tf_flat.setText(String.valueOf(customer.getFlat()));
tf_code.setText(String.valueOf(customer.getCode()));
tf_oplata_nomer.setText(String.valueOf(customer.getNomer_oplat()));
}
});
當我從組合框中選擇項目時,而不是當我鍵入組合框或其他時,我需要執行此操作。那麼我需要什麼actionevent,而不是setOnAction?
嘗試添加監聽選擇模型的'selectedIndexProperty'? –