Example usage for javafx.util Callback Callback

List of usage examples for javafx.util Callback Callback

Introduction

In this page you can find the example usage for javafx.util Callback Callback.

Prototype

Callback

Source Link

Usage

From source file:herudi.controller.microMarketController.java

/**
 * Initializes the controller class./*  www. ja  va 2s  .  c  o  m*/
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    Platform.runLater(() -> {
        ApplicationContext ctx = config.getInstance().getApplicationContext();
        crud = ctx.getBean(interMicro.class);
        listData = FXCollections.observableArrayList();
        status = 0;
        config2.setModelColumn(colAreaLength, "areaLength");
        config2.setModelColumn(colAreaWidth, "areaWidth");
        config2.setModelColumn(colRadius, "radius");
        config2.setModelColumn(colZip, "zipCode");
        colAction.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<Object, Boolean>, ObservableValue<Boolean>>() {
                    @Override
                    public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<Object, Boolean> p) {
                        return new SimpleBooleanProperty(p.getValue() != null);
                    }
                });
        colAction.setCellFactory(new Callback<TableColumn<Object, Boolean>, TableCell<Object, Boolean>>() {
            @Override
            public TableCell<Object, Boolean> call(TableColumn<Object, Boolean> p) {
                return new ButtonCell(tableData);
            }
        });
        selectWithService();
    });
    // TODO
}

From source file:retsys.client.controller.CreditNoteController.java

/**
 * Initializes the controller class.//from  ww w .ja v  a2s  .  co  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    creationDate.setValue(LocalDate.now());

    itemName.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, String>("itemName"));
    itemAmount.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, Double>("itemAmount"));
    returnQuantity.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, Double>("returnQuantity"));
    confirm.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, Boolean>("confirm"));
    confirm.setCellFactory(CheckBoxTableCell.forTableColumn(confirm));

    creditNoteDetail.getColumns().setAll(itemName, itemAmount, returnQuantity, confirm);

    AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    System.out.println("here..." + object);
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
    //event handler for setting other item fields with values from selected Item object
    //fires after autocompletion
    bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            name.setText(item.getName() + " (ID:" + item.getId() + ")");
            brand.setText(item.getBrand());
            model.setText(null); //?? add model?
            amount.setText(item.getRate().toString());
            quantity.setText(item.getQuantity().toString());

        }
    });

    TextFields.bindAutoCompletion(vendor,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() {

                @Override
                public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Vendor> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("vendors", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Vendor>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Vendor>() {

                @Override
                public String toString(Vendor object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Vendor fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
}

From source file:retsys.client.controller.PurchaseOrderController.java

/**
 * Initializes the controller class./*w  w w .  j  av a  2 s.  c o  m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    po_date.setValue(LocalDate.now());

    loc_of_material.setCellValueFactory(new PropertyValueFactory<POItem, String>("location"));
    material_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("name"));
    brand_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("brand"));
    model_code.setCellValueFactory(new PropertyValueFactory<POItem, String>("model"));
    quantity.setCellValueFactory(new PropertyValueFactory<POItem, Integer>("quantity"));

    poDetail.getColumns().setAll(loc_of_material, material_name, brand_name, model_code, quantity);

    AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    System.out.println("here..." + object);
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
    //event handler for setting other item fields with values from selected Item object
    //fires after autocompletion
    bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            txt_brand.setText(item.getBrand());
            txt_location.setUserData(item.getId());
            txt_model.setText(null); // item doesn't have this field. add??
        }
    });

    TextFields.bindAutoCompletion(project,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() {

                @Override
                public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Project> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("projects", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Project>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Project>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Project>() {

                @Override
                public String toString(Project object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Project fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });

    TextFields.bindAutoCompletion(vendor,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() {

                @Override
                public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Vendor> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("vendors", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Vendor>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Vendor>() {

                @Override
                public String toString(Vendor object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Vendor fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
}

From source file:context.ui.control.tabular.TabularViewController.java

private void initialTableData() {
    data.loadTableData();//from   w w  w. j  a v  a  2 s .c o m
    //        double minWidth = tableView.getWidth() / data.getHeaders().size();
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    int index = 0;
    for (String header : data.getHeaders()) {
        final int j = index;
        TableColumn tableColumn = new TableColumn(header);

        tableColumn.setComparator(new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                if (NumberUtils.isNumber(s1) && NumberUtils.isNumber(s2)) {
                    return Double.compare(Double.parseDouble(s1), Double.parseDouble(s2));
                }
                return Collator.getInstance().compare(s1, s2);
            }
        });
        tableColumn.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<List<String>, String>, ObservableValue<String>>() {
                    public ObservableValue<String> call(TableColumn.CellDataFeatures<List<String>, String> p) {
                        final String val = p.getValue().get(j);
                        if (isRoundDoubles() && NumberUtils.isNumber(val) && val.contains(".")) {
                            DecimalFormat df = new DecimalFormat("#.##");
                            Double d = Double.parseDouble(val);
                            return new SimpleStringProperty(df.format(d));
                        } else {
                            return new SimpleStringProperty(val);
                        }
                    }
                });
        index++;
        tableView.getColumns().add(tableColumn);
        //            if (index < data.getHeaders().size() - 1) {
        //                tableColumn.setMinWidth(minWidth);
        //            }
        //            System.out.println("width=" + tableColumn.getMinWidth());
    }
    System.out.println("columns Count:" + tableView.getColumns().size());
    //  which will make your table view dynamic 
    //        ObservableList<ObservableList> csvData = FXCollections.observableArrayList();
    //
    //        for (List<StringProperty> dataList : data.getRows()) {
    //            ObservableList<String> row = FXCollections.observableArrayList();
    //            for (StringProperty rowData : dataList) {
    //                row.add(rowData.get());
    //            }
    //            csvData.add(row); // add each row to cvsData
    //        }
    System.out.println("Rows Count=" + data.getRows().size());
    tableView.setItems(data.getRows()); // finally add data to tableview
    System.out.println("after Rows Count=" + tableView.getItems().size());

}

From source file:com.QuarkLabs.BTCeClientJavaFX.PublicTradesController.java

@FXML
void initialize() {
    assert publicTradesTable != null : "fx:id=\"publicTradesTable\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableAmountColumn != null : "fx:id=\"publicTradesTableAmountColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableDateColumn != null : "fx:id=\"publicTradesTableDateColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableItemColumn != null : "fx:id=\"publicTradesTableItemColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTablePriceColumn != null : "fx:id=\"publicTradesTablePriceColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTablePriceCurrencyColumn != null : "fx:id=\"publicTradesTablePriceCurrencyColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableTIDColumn != null : "fx:id=\"publicTradesTableTIDColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableTradeTypeColumn != null : "fx:id=\"publicTradesTableTradeTypeColumn\" was not injected: check your FXML file 'markettrades.fxml'.";

    publicTradesTable.setItems(publicTrades);
    publicTradesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    publicTradesTableAmountColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("amount"));
    publicTradesTableDateColumn.setCellValueFactory(
            new Callback<TableColumn.CellDataFeatures<PublicTrade, String>, ObservableValue<String>>() {
                @Override//from   w ww.j a v a2 s.  c  o m
                public ObservableValue<String> call(
                        TableColumn.CellDataFeatures<PublicTrade, String> publicTradeStringCellDataFeatures) {
                    PublicTrade publicTrade = publicTradeStringCellDataFeatures.getValue();
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(publicTrade.getDate() * 1000);
                    DateFormat dateFormat = DateFormat.getDateTimeInstance();
                    return new SimpleStringProperty(dateFormat.format(calendar.getTime()));
                }
            });
    publicTradesTableItemColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("item"));
    publicTradesTablePriceColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("price"));
    publicTradesTablePriceCurrencyColumn
            .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("priceCurrency"));
    publicTradesTableTIDColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Long>("tid"));
    publicTradesTableTradeTypeColumn
            .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("tradeType"));

    Task<JSONArray> loadPublicTrades = new Task<JSONArray>() {
        @Override
        protected JSONArray call() throws Exception {
            return App.getPublicTrades(pair);
        }
    };
    loadPublicTrades.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
        @Override
        public void handle(WorkerStateEvent workerStateEvent) {
            JSONArray jsonArray = (JSONArray) workerStateEvent.getSource().getValue();
            publicTrades.clear();
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject item = jsonArray.getJSONObject(i);
                PublicTrade publicTrade = new PublicTrade();
                publicTrade.setDate(item.getLong("date"));
                publicTrade.setAmount(item.getDouble("amount"));
                publicTrade.setItem(item.getString("item"));
                publicTrade.setPrice(item.getDouble("price"));
                publicTrade.setPriceCurrency(item.getString("price_currency"));
                publicTrade.setTid(item.getLong("tid"));
                publicTrade.setTradeType(item.getString("trade_type"));
                publicTrades.add(publicTrade);
            }
        }
    });
    Thread thread = new Thread(loadPublicTrades);
    thread.start();
}

From source file:org.jacp.demo.components.ContactTableViewComponent.java

private Callback<TableView<Contact>, TableRow<Contact>> createRowCallback() {
    return new Callback<TableView<Contact>, TableRow<Contact>>() {

        @Override/*from  ww w.j  ava2 s  .  c o  m*/
        public TableRow<Contact> call(final TableView<Contact> arg0) {
            final TableRow<Contact> row = new TableRow<Contact>() {
                @Override
                public void updateItem(final Contact contact, final boolean emty) {
                    super.updateItem(contact, emty);
                    if (contact != null) {
                        this.setOnMouseClicked(new EventHandler<Event>() {
                            @Override
                            public void handle(final Event arg0) {
                                // send contact to TableView
                                // component to show containing
                                // contacts
                                context.send(GlobalConstants.cascade(
                                        GlobalConstants.PerspectiveConstants.DEMO_PERSPECTIVE,
                                        GlobalConstants.CallbackConstants.CALLBACK_ANALYTICS), contact);
                                context.send(
                                        GlobalConstants.cascade(
                                                GlobalConstants.PerspectiveConstants.DEMO_PERSPECTIVE,
                                                GlobalConstants.ComponentConstants.COMPONENT_DETAIL_VIEW),
                                        contact);

                            }
                        });
                    }
                }
            };
            return row;
        }

    };
}

From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java

public ClassTree(JEVisDataSource ds) {
    super();// w  w  w  .  ja v a  2 s .co  m
    try {
        _ds = ds;

        _itemCache = new HashMap<>();
        _graphicCache = new HashMap<>();
        _itemChildren = new HashMap<>();

        JEVisClass root = new JEVisRootClass(ds);
        TreeItem<JEVisClass> rootItem = buildItem(root);

        setShowRoot(true);
        rootItem.setExpanded(true);

        getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        _editor.setTreeView(this);

        setCellFactory(new Callback<TreeView<JEVisClass>, TreeCell<JEVisClass>>() {

            //                @Override
            //                public TreeCell<JEVisClass> call(TreeView<JEVisClass> p) {
            //                    return new ClassCell();
            //                }
            @Override
            public TreeCell<JEVisClass> call(TreeView<JEVisClass> param) {
                return new TreeCell<JEVisClass>() {
                    //                        private ImageView imageView = new ImageView();

                    @Override
                    protected void updateItem(JEVisClass item, boolean empty) {
                        super.updateItem(item, empty);

                        if (!empty) {
                            ClassGraphic gc = getClassGraphic(item);

                            setContextMenu(gc.getContexMenu());
                            //                                setText(item);
                            setGraphic(gc.getGraphic());
                        } else {
                            setText(null);
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<JEVisClass>>() {

            @Override
            public void changed(ObservableValue<? extends TreeItem<JEVisClass>> ov, TreeItem<JEVisClass> t,
                    TreeItem<JEVisClass> t1) {
                try {
                    if (t1 != null) {
                        _editor.setJEVisClass(t1.getValue());
                    }
                } catch (Exception ex) {
                    System.out.println("Error while changing editor: " + ex);
                }

            }
        });

        addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {

            @Override
            public void handle(KeyEvent t) {
                if (t.getCode() == KeyCode.F2) {
                    System.out.println("F2 rename event");
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            fireEventRename();
                        }
                    });

                } else if (t.getCode() == KeyCode.DELETE) {

                    fireDelete(getSelectionModel().getSelectedItem().getValue());
                }
            }

        });

        setId("objecttree");

        getStylesheets().add("/styles/Styles.css");
        setPrefWidth(500);

        setRoot(rootItem);
        setEditable(true);

    } catch (Exception ex) {
        //            Logger.getLogger(ObjectTree.class.getName()).log(Level.SEVERE, null, ex);
        ex.printStackTrace();
    }

}

From source file:herudi.controller.productController.java

/**
 * Initializes the controller class./* w w  w. j a v a2  s.  c o m*/
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    Platform.runLater(() -> {
        ApplicationContext ctx = config.getInstance().getApplicationContext();
        crud = ctx.getBean(interProduct.class);
        listData = FXCollections.observableArrayList();
        status = 0;
        available = "";
        config2.setModelColumn(colAvailable, "available");
        config2.setModelColumn(colDescription, "description");
        config2.setModelColumn(colManufacturerIid, "manufacturerId");
        config2.setModelColumn(colMarkup, "markup");
        config2.setModelColumn(colProductCode, "productCode");
        config2.setModelColumn(colProductId, "productId");
        config2.setModelColumn(colPurchaseCost, "formatCost");
        config2.setModelColumn(colQuantityOnHand, "quantityOnHand");
        colAction.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<Object, Boolean>, ObservableValue<Boolean>>() {
                    @Override
                    public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<Object, Boolean> p) {
                        return new SimpleBooleanProperty(p.getValue() != null);
                    }
                });
        colAction.setCellFactory(new Callback<TableColumn<Object, Boolean>, TableCell<Object, Boolean>>() {
            @Override
            public TableCell<Object, Boolean> call(TableColumn<Object, Boolean> p) {
                return new ButtonCell(tableData);
            }
        });
        selectWithService();
        displayManufacturer();
        displayProductCode();
    });
    // TODO
}

From source file:retsys.client.controller.DeliveryChallanController.java

/**
 * Initializes the controller class.//from w w  w.  ja v  a 2  s . c o m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    dc_date.setValue(LocalDate.now());

    material_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("name"));
    brand_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("brand"));
    model_code.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model"));
    quantity.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("quantity"));
    units.setCellValueFactory(new PropertyValueFactory<DCItem, String>("units"));
    amount.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("amount"));

    dcDetail.getColumns().setAll(material_name, brand_name, model_code, quantity, units, amount);
    // TODO

    AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    System.out.println("here..." + object);
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
    //event handler for setting other item fields with values from selected Item object
    //fires after autocompletion
    bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            txt_name.setUserData(item.getId());
            txt_brand.setText(item.getBrand());
            txt_model.setText(item.getBrand()); // item doesn't have this field. add??
            txt_rate.setText(String.valueOf(item.getRate()));
            txt_units.setText(item.getUnit());
            txt_qty.setText("");
            txt_amount.setText("");
            txt_qty.requestFocus();
        }
    });

    AutoCompletionBinding<Project> bindForProject = TextFields.bindAutoCompletion(project,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() {

                @Override
                public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Project> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("projects", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Project>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Project>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Project>() {

                @Override
                public String toString(Project object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Project fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });

    txt_qty.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (!newValue) {
                calcAmount();
            }
        }
    });
}

From source file:herudi.controller.customerController.java

/**
 * Initializes the controller class./* w w  w . j  a va  2  s.  c  o  m*/
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    Platform.runLater(() -> {
        ApplicationContext ctx = config.getInstance().getApplicationContext();
        crud = ctx.getBean(interCustomer.class);
        listData = FXCollections.observableArrayList();
        status = 0;
        config2.setModelColumn(colAdderss1, "addressline1");
        config2.setModelColumn(colAddress2, "addressline2");
        config2.setModelColumn(colCity, "city");
        config2.setModelColumn(colCreditLimit, "creditLimit");
        config2.setModelColumn(colCustomerId, "customerId");
        config2.setModelColumn(colDiscountCode, "discountCode");
        config2.setModelColumn(colEmail, "email");
        config2.setModelColumn(colFax, "fax");
        config2.setModelColumn(colName, "name");
        config2.setModelColumn(colPhone, "phone");
        config2.setModelColumn(colState, "state");
        config2.setModelColumn(colZip, "zip");
        colAction.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<Object, Boolean>, ObservableValue<Boolean>>() {
                    @Override
                    public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<Object, Boolean> p) {
                        return new SimpleBooleanProperty(p.getValue() != null);
                    }
                });
        colAction.setCellFactory(new Callback<TableColumn<Object, Boolean>, TableCell<Object, Boolean>>() {
            @Override
            public TableCell<Object, Boolean> call(TableColumn<Object, Boolean> p) {
                return new ButtonCell(tableData);
            }
        });
        selectWithService();
        displayDiscountCode();
        displayZip();
    });
    // TODO
}