List of usage examples for javafx.scene.input KeyEvent consume
public void consume()
From source file:de.serverfrog.pw.ui.MainViewController.java
/** * * @param event event//from w w w . j av a 2 s . c o m */ @FXML public void onPasswordLengthKeyTyped(KeyEvent event) { if (!StringUtils.isNumeric(event.getCharacter())) { event.consume(); } }
From source file:org.cryptomator.ui.controllers.SettingsController.java
private void filterNumericKeyEvents(KeyEvent t) { if (t.getCharacter() == null || t.getCharacter().length() == 0) { return;/* ww w . ja v a 2 s .c o m*/ } char c = CharUtils.toChar(t.getCharacter()); if (!(CharUtils.isAsciiNumeric(c) || c == '_')) { t.consume(); } }
From source file:org.cryptomator.ui.InitializeController.java
public void filterAlphanumericKeyEvents(KeyEvent t) { if (t.getCharacter() == null || t.getCharacter().length() == 0) { return;/* ww w. j a va 2 s.co m*/ } char c = t.getCharacter().charAt(0); if (!CharUtils.isAsciiAlphanumeric(c)) { t.consume(); } }
From source file:account.management.controller.SalaryVoucherController.java
/** * Initializes the controller class.//from w w w.j a v a2 s. c o m */ @Override public void initialize(URL url, ResourceBundle rb) { new Thread(() -> { try { Thread.sleep(5000); this.amount_words.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(final KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { System.out.println("attempting to submit deposit voucher"); //Stop letting it do anything else keyEvent.consume(); try { onSubmitButtonClick(null); } catch (ParseException ex) { Logger.getLogger(SalaryVoucherController.class.getName()).log(Level.SEVERE, null, ex); } } } }); } catch (InterruptedException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } }).start(); }
From source file:account.management.controller.expenseVoucherController.java
@Override public void initialize(URL location, ResourceBundle resources) { new AutoCompleteComboBoxListener<>(this.location); this.location.setOnHiding((e) -> { Location a = this.location.getSelectionModel().getSelectedItem(); this.location.setEditable(false); this.location.getSelectionModel().select(a); });/*from w ww . jav a2 s.co m*/ this.location.setOnShowing((e) -> { this.location.setEditable(true); }); try { HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/locations").asJson(); JSONArray array = res.getBody().getArray(); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); this.location.getItems() .add(new Location(obj.getInt("id"), obj.getString("name"), obj.getString("details"))); } this.amount.setOnKeyReleased((e) -> { calculateTotal(); }); } catch (Exception e) { } new Thread(() -> { try { Thread.sleep(5000); this.save.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(final KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { System.out.println("attempting to submit expense voucher"); //Stop letting it do anything else keyEvent.consume(); onSaveButtonClick(null); } } }); } catch (InterruptedException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } }).start(); }
From source file:com.anavationllc.o2jb.ConfigurationApp.java
private EventHandler<KeyEvent> getKeyEventHandler() { if (keyEventHandler == null) { keyEventHandler = new EventHandler<KeyEvent>() { @Override//w ww . j av a 2s . c o m public void handle(KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { if (canSubmit()) { keyEvent.consume(); okBtn.fire(); } } else if (keyEvent.getCode() == KeyCode.ESCAPE) { keyEvent.consume(); cancelBtn.fire(); } else { okBtn.setDisable(!canSubmit()); } } }; } return keyEventHandler; }
From source file:Jigs_Desktop_Client.GUI.FXMLDocumentController.java
@Override public void initialize(URL url, ResourceBundle rb) { this.alert("resources/app_launch.mp3"); this.user_name.requestFocus(); this.btn_logout.setDisable(true); this.jc.setStatus(from_user, "online"); this.my_circle_list.setCellFactory(new Callback<ListView<UserStatus>, ListCell<UserStatus>>() { @Override/*from w w w. j a v a 2 s . com*/ public ListCell<UserStatus> call(ListView<UserStatus> userObj) { ListCell<UserStatus> cell = new ListCell<UserStatus>() { @Override protected void updateItem(UserStatus usrObj, boolean btnl) { super.updateItem(usrObj, btnl); if (usrObj != null) { String filename = usrObj.getStatus(); if (filename == null || filename.equals("") || filename.equals("null")) filename = "offline"; else System.out.println(filename); Image img = new Image( getClass().getResource("resources/" + filename + ".png").toExternalForm()); ImageView imv = new ImageView(img); setGraphic(imv); setText(usrObj.getUsername()); } } }; return cell; } }); this.main_panel.setBackground(Background.EMPTY); this.text_message.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { sendMessage(null); keyEvent.consume(); } } }); }
From source file:account.management.controller.POVoucherController.java
/** * Initializes the controller class.//from w w w. ja v a2 s .c o m */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO balance.focusedProperty().addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) { Platform.runLater(new Runnable() { @Override public void run() { balance.requestFocus(); balance.selectAll(); } }); } }); this.container.getChildren().remove(0); new Thread(() -> { try { Thread.sleep(5000); this.total_price.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(final KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { System.out.println("attempting to submit deposit voucher"); //Stop letting it do anything else keyEvent.consume(); try { onSubmitButtonClick(null); } catch (ParseException ex) { Logger.getLogger(SalaryVoucherController.class.getName()).log(Level.SEVERE, null, ex); } } } }); } catch (InterruptedException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } }).start(); }
From source file:org.cryptomator.ui.controllers.UnlockController.java
private void filterAlphanumericKeyEvents(KeyEvent t) { if (t.getCharacter() == null || t.getCharacter().length() == 0) { return;// w w w . j a va 2s . c o m } char c = CharUtils.toChar(t.getCharacter()); if (!(CharUtils.isAsciiAlphanumeric(c) || c == '_')) { t.consume(); } }
From source file:com.properned.application.SystemController.java
public void initialize() { logger.info("Initialize System controller"); localeButton.disableProperty().bind(multiLanguageProperties.isLoadedProperty().not()); saveButton.disableProperty().bind(multiLanguageProperties.isDirtyProperty().not() .or(multiLanguageProperties.isLoadedProperty().not())); Stage primaryStage = Properned.getInstance().getPrimaryStage(); primaryStage.titleProperty()// www . ja v a 2 s. com .bind(multiLanguageProperties.baseNameProperty() .concat(Bindings.when(multiLanguageProperties.isLoadedProperty()) .then(new SimpleStringProperty(" (") .concat(multiLanguageProperties.parentDirectoryPathProperty()).concat(")")) .otherwise("")) .concat(Bindings.when(multiLanguageProperties.isDirtyProperty()).then(" *").otherwise(""))); FilteredList<String> filteredList = new FilteredList<>(multiLanguageProperties.getListMessageKey(), new Predicate<String>() { @Override public boolean test(String t) { String filter = filterText.getText(); if (filter == null || filter.equals("")) { return true; } return t.contains(filter); } }); SortedList<String> sortedList = new SortedList<>(filteredList, new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }); messageKeyList.setItems(sortedList); filterText.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { // Filter the list filteredList.setPredicate(new Predicate<String>() { @Override public boolean test(String t) { String filter = filterText.getText(); if (filter == null || filter.equals("")) { return true; } return t.contains(filter); } }); // check the add button disabled status if (isKeyCanBeAdded(newValue)) { addButton.setDisable(false); } else { addButton.setDisable(true); } } }); ChangeListener<String> changeMessageListener = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { logger.info("Message key selection changed : " + newValue); valueList.setItems(FXCollections.observableArrayList()); valueList.setItems(FXCollections .observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet())); } }; messageKeyList.getSelectionModel().selectedItemProperty().addListener(changeMessageListener); messageKeyList.setCellFactory(c -> new MessageKeyListCell(multiLanguageProperties)); valueList.setCellFactory(c -> new ValueListCell(multiLanguageProperties, messageKeyList)); filterText.setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.DOWN) { messageKeyList.requestFocus(); event.consume(); } else if (event.getCode() == KeyCode.ENTER) { addKey(); event.consume(); } } }); }