×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: sumesh tg
Added: Feb 7, 2017 9:15 AM
Views: 25
This snippet shows how to do auto completion with controlfx
  1.                 /* ======================== Re-Construct List For Autocompletion ==================== */
  2.                 ObservableList<EnquiryDetailsSearchPOJO> listAutoCompletion = FXCollections.observableArrayList();
  3.                 for (EnquiryDetailsSearchPOJO autoBEAN : enquiryListDeSerialize) {
  4.                     EnquiryDetailsSearchPOJO autoCompletionBEAN = new EnquiryDetailsSearchPOJO() {
  5.                         @Override
  6.                         public String toString() {
  7.                             return autoBEAN.getConatctName() + " - " + autoBEAN.getContactNumber();
  8.                         }
  9.                     };
  10.                     BeanUtils.copyProperties(autoBEAN, autoCompletionBEAN);
  11.                     listAutoCompletion.add(autoCompletionBEAN);
  12.                 }
  13.                 /* ======================== Auto Completion On CandidateName ==================== */
  14.                 AutoCompletionBinding<EnquiryDetailsSearchPOJO> autoCompCandidate = TextFields.bindAutoCompletion(txtCandidateName, listAutoCompletion);
  15.                 autoCompCandidate.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<EnquiryDetailsSearchPOJO>>() {
  16.                     @Override
  17.                     public void handle(AutoCompletionBinding.AutoCompletionEvent<EnquiryDetailsSearchPOJO> event) {
  18.                         ENQUIRY_ID = event.getCompletion().getEnquiryId();
  19.                         chkMailId.setText(event.getCompletion().getContactMail());
  20. //                        System.out.println("Enquiry Id :: " + ENQUIRY_ID);
  21.                         PROMO_CODE_ID = null;
  22.                     }
  23.                 });