/** * Sets up the GUI, ensuring that everything is loaded nicely. * * @param location * @param resources */ public void initialize(URL location, ResourceBundle resources) { filter = new Filter(); Set<String> books = new HashSet<>(); for (Book book : Book.values()) { books.add(book.toString()); } filter.setBooks(books); results.setItems(listItems); String index = "java_ebook_search/index"; String home = "/java_ebook_search/view/index.html"; try { search = new Search(index); commonTerms = TextFields.bindAutoCompletion(query, search.getAutocomplete()); commonTerms.setVisibleRowCount(10); sc = new SpellCheck(); webEngine = webView.getEngine(); webEngine.load(getClass().getResource(home).toString()); results .getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> loadResult(newValue)); } catch (NullPointerException e) { System.out.println("It's happened again, ignore it"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
/** * Adds string to our common search terms * * @param newWord */ private void autoCompletionLearnWord(String newWord) { search.addTerm(newWord); // we dispose the old binding and recreate a new binding if (commonTerms != null) { commonTerms.dispose(); } commonTerms = TextFields.bindAutoCompletion(query, search.getAutocomplete()); }