List of usage examples for javafx.scene.input KeyEvent getCode
public final KeyCode getCode()
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Handle action related to input (in this case specifically only responds * to keyboard event CTRL-A)./*from w w w . j av a 2 s. c o m*/ * * @param event Input event. */ @FXML public void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { provideAboutFunctionality(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.R) { showReportOptionsDialog(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.O) { openFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.S) { saveFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.L) { showLoggerDialog(); } } }
From source file:Main.java
@Override public void start(final Stage stage) { stage.setTitle("Xylophone"); camOffset.getChildren().add(cam);/* w ww .j av a2 s .co m*/ resetCam(); final Scene scene = new Scene(camOffset, 800, 600, true); scene.setFill(new RadialGradient(225, 0.85, 300, 300, 500, false, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0f, Color.BLUE), new Stop(1f, Color.LIGHTBLUE) })); scene.setCamera(new PerspectiveCamera()); final AudioClip bar1Note = new AudioClip(Main.class.getResource("audio/Note1.wav").toString()); final AudioClip bar2Note = new AudioClip(Main.class.getResource("audio/Note2.wav").toString()); final AudioClip bar3Note = new AudioClip(Main.class.getResource("audio/Note3.wav").toString()); final AudioClip bar4Note = new AudioClip(Main.class.getResource("audio/Note4.wav").toString()); final AudioClip bar5Note = new AudioClip(Main.class.getResource("audio/Note5.wav").toString()); final AudioClip bar6Note = new AudioClip(Main.class.getResource("audio/Note6.wav").toString()); final AudioClip bar7Note = new AudioClip(Main.class.getResource("audio/Note7.wav").toString()); final AudioClip bar8Note = new AudioClip(Main.class.getResource("audio/Note8.wav").toString()); Group rectangleGroup = new Group(); rectangleGroup.getTransforms().add(shear); rectangleGroup.setDepthTest(DepthTest.ENABLE); double xStart = 260.0; double xOffset = 30.0; double yPos = 300.0; double zPos = 0.0; double barWidth = 22.0; double barDepth = 7.0; // Base1 Cube base1Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base1Cube.setTranslateX(xStart + 135); base1Cube.setTranslateZ(yPos + 20.0); base1Cube.setTranslateY(11.0); base1Cube.setScaleX(barWidth * 11.5); base1Cube.setScaleZ(10.0); base1Cube.setScaleY(barDepth * 2.0); // Base2 Cube base2Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base2Cube.setTranslateX(xStart + 135); base2Cube.setTranslateZ(yPos - 20.0); base2Cube.setTranslateY(11.0); base2Cube.setScaleX(barWidth * 11.5); base2Cube.setScaleZ(10.0); base2Cube.setScaleY(barDepth * 2.0); // Bar1 Cube bar1Cube = new Cube(1.0, Color.PURPLE, 1.0); bar1Cube.setTranslateX(xStart + 1 * xOffset); bar1Cube.setTranslateZ(yPos); bar1Cube.setScaleX(barWidth); bar1Cube.setScaleZ(100.0); bar1Cube.setScaleY(barDepth); // Bar2 Cube bar2Cube = new Cube(1.0, Color.BLUEVIOLET, 1.0); bar2Cube.setTranslateX(xStart + 2 * xOffset); bar2Cube.setTranslateZ(yPos); bar2Cube.setScaleX(barWidth); bar2Cube.setScaleZ(95.0); bar2Cube.setScaleY(barDepth); // Bar3 Cube bar3Cube = new Cube(1.0, Color.BLUE, 1.0); bar3Cube.setTranslateX(xStart + 3 * xOffset); bar3Cube.setTranslateZ(yPos); bar3Cube.setScaleX(barWidth); bar3Cube.setScaleZ(90.0); bar3Cube.setScaleY(barDepth); // Bar4 Cube bar4Cube = new Cube(1.0, Color.GREEN, 1.0); bar4Cube.setTranslateX(xStart + 4 * xOffset); bar4Cube.setTranslateZ(yPos); bar4Cube.setScaleX(barWidth); bar4Cube.setScaleZ(85.0); bar4Cube.setScaleY(barDepth); // Bar5 Cube bar5Cube = new Cube(1.0, Color.GREENYELLOW, 1.0); bar5Cube.setTranslateX(xStart + 5 * xOffset); bar5Cube.setTranslateZ(yPos); bar5Cube.setScaleX(barWidth); bar5Cube.setScaleZ(80.0); bar5Cube.setScaleY(barDepth); // Bar6 Cube bar6Cube = new Cube(1.0, Color.YELLOW, 1.0); bar6Cube.setTranslateX(xStart + 6 * xOffset); bar6Cube.setTranslateZ(yPos); bar6Cube.setScaleX(barWidth); bar6Cube.setScaleZ(75.0); bar6Cube.setScaleY(barDepth); // Bar7 Cube bar7Cube = new Cube(1.0, Color.ORANGE, 1.0); bar7Cube.setTranslateX(xStart + 7 * xOffset); bar7Cube.setTranslateZ(yPos); bar7Cube.setScaleX(barWidth); bar7Cube.setScaleZ(70.0); bar7Cube.setScaleY(barDepth); // Bar8 Cube bar8Cube = new Cube(1.0, Color.RED, 1.0); bar8Cube.setTranslateX(xStart + 8 * xOffset); bar8Cube.setTranslateZ(yPos); bar8Cube.setScaleX(barWidth); bar8Cube.setScaleZ(65.0); bar8Cube.setScaleY(barDepth); bar1Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar1Note.play(); } }); bar2Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar2Note.play(); } }); bar3Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar3Note.play(); } }); bar4Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar4Note.play(); } }); bar5Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar5Note.play(); } }); bar6Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar6Note.play(); } }); bar7Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar7Note.play(); } }); bar8Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar8Note.play(); } }); rectangleGroup.getChildren().addAll(base1Cube, base2Cube, bar1Cube, bar2Cube, bar3Cube, bar4Cube, bar5Cube, bar6Cube, bar7Cube, bar8Cube); rectangleGroup.setScaleX(2.5); rectangleGroup.setScaleY(2.5); rectangleGroup.setScaleZ(2.5); cam.getChildren().add(rectangleGroup); double halfSceneWidth = 375; // scene.getWidth()/2.0; double halfSceneHeight = 275; // scene.getHeight()/2.0; cam.p.setX(halfSceneWidth); cam.ip.setX(-halfSceneWidth); cam.p.setY(halfSceneHeight); cam.ip.setY(-halfSceneHeight); frameCam(stage, scene); scene.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mousePosX = me.getX(); mousePosY = me.getY(); mouseOldX = me.getX(); mouseOldY = me.getY(); //System.out.println("scene.setOnMousePressed " + me); } }); scene.setOnMouseDragged(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mouseOldX = mousePosX; mouseOldY = mousePosY; mousePosX = me.getX(); mousePosY = me.getY(); mouseDeltaX = mousePosX - mouseOldX; mouseDeltaY = mousePosY - mouseOldY; if (me.isAltDown() && me.isShiftDown() && me.isPrimaryButtonDown()) { double rzAngle = cam.rz.getAngle(); cam.rz.setAngle(rzAngle - mouseDeltaX); } else if (me.isAltDown() && me.isPrimaryButtonDown()) { double ryAngle = cam.ry.getAngle(); cam.ry.setAngle(ryAngle - mouseDeltaX); double rxAngle = cam.rx.getAngle(); cam.rx.setAngle(rxAngle + mouseDeltaY); } else if (me.isShiftDown() && me.isPrimaryButtonDown()) { double yShear = shear.getY(); shear.setY(yShear + mouseDeltaY / 1000.0); double xShear = shear.getX(); shear.setX(xShear + mouseDeltaX / 1000.0); } else if (me.isAltDown() && me.isSecondaryButtonDown()) { double scale = cam.s.getX(); double newScale = scale + mouseDeltaX * 0.01; cam.s.setX(newScale); cam.s.setY(newScale); cam.s.setZ(newScale); } else if (me.isAltDown() && me.isMiddleButtonDown()) { double tx = cam.t.getX(); double ty = cam.t.getY(); cam.t.setX(tx + mouseDeltaX); cam.t.setY(ty + mouseDeltaY); } } }); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (KeyCode.A.equals(ke.getCode())) { resetCam(); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.F.equals(ke.getCode())) { frameCam(stage, scene); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.SPACE.equals(ke.getCode())) { if (stage.isFullScreen()) { stage.setFullScreen(false); frameCam(stage, scene); } else { stage.setFullScreen(true); frameCam(stage, scene); } } } }); stage.setScene(scene); stage.show(); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblContexts_OnKeyPressed(KeyEvent keyEvent) { if (keyEvent.isControlDown()) { if (keyEvent.getCode().getName().equals("C")) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); Context context = tblContexts.getSelectionModel().getSelectedItem(); content.putString(context.getTextSegment()); clipboard.setContent(content); }//from w w w .j a v a 2 s .c o m } }
From source file:nars.rl.util.ThreeDView.java
private void handleKeyboard(Scene scene, final Node root) { final boolean moveCamera = true; scene.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override/*from w w w . ja v a 2 s . c o m*/ public void handle(KeyEvent event) { Duration currentTime; switch (event.getCode()) { case Z: if (event.isShiftDown()) { cameraXform.ry.setAngle(0.0); cameraXform.rx.setAngle(0.0); camera.setTranslateZ(-300.0); } cameraXform2.t.setX(0.0); cameraXform2.t.setY(0.0); break; case X: if (event.isControlDown()) { if (axisGroup.isVisible()) { axisGroup.setVisible(false); } else { axisGroup.setVisible(true); } } break; case S: if (event.isControlDown()) { if (space.isVisible()) { space.setVisible(false); } else { space.setVisible(true); } } break; case SPACE: if (timelinePlaying) { timeline.pause(); timelinePlaying = false; } else { timeline.play(); timelinePlaying = true; } break; case UP: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setY(cameraXform2.t.getY() - 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 10.0 * ALT_MULTIPLIER); } else if (event.isControlDown()) { cameraXform2.t.setY(cameraXform2.t.getY() - 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 2.0 * ALT_MULTIPLIER); } else if (event.isShiftDown()) { double z = camera.getTranslateZ(); double newZ = z + 5.0 * SHIFT_MULTIPLIER; camera.setTranslateZ(newZ); } break; case DOWN: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setY(cameraXform2.t.getY() + 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 10.0 * ALT_MULTIPLIER); } else if (event.isControlDown()) { cameraXform2.t.setY(cameraXform2.t.getY() + 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 2.0 * ALT_MULTIPLIER); } else if (event.isShiftDown()) { double z = camera.getTranslateZ(); double newZ = z - 5.0 * SHIFT_MULTIPLIER; camera.setTranslateZ(newZ); } break; case RIGHT: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setX(cameraXform2.t.getX() + 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 10.0 * ALT_MULTIPLIER); } else if (event.isControlDown()) { cameraXform2.t.setX(cameraXform2.t.getX() + 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 2.0 * ALT_MULTIPLIER); } break; case LEFT: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setX(cameraXform2.t.getX() - 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 10.0 * ALT_MULTIPLIER); // - } else if (event.isControlDown()) { cameraXform2.t.setX(cameraXform2.t.getX() - 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 2.0 * ALT_MULTIPLIER); // - } break; } } }); }
From source file:pl.baczkowicz.mqttspy.ui.NewPublicationController.java
public void initialize(URL location, ResourceBundle resources) { timeBasedFilter = new TimeBasedKeyEventFilter(15); publicationTopicText.setItems(publicationTopics); formatGroup.getToggles().get(0).setUserData(ConversionMethod.PLAIN); formatGroup.getToggles().get(1).setUserData(ConversionMethod.HEX_DECODE); formatGroup.selectToggle(formatGroup.getToggles().get(0)); formatGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override/*from w ww .j a v a2s .c om*/ public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { // If plain has been selected if (newValue != null) { if (formatGroup.getSelectedToggle().getUserData().equals(ConversionMethod.PLAIN)) { showAsPlain(); } else { showAsHex(); } } } }); publicationTopicText.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { switch (keyEvent.getCode()) { case ENTER: { if (connected && timeBasedFilter.processEvent(keyEvent)) { publish(); keyEvent.consume(); } break; } case DIGIT0: { restoreFromKeypress(keyEvent, 0); break; } case DIGIT1: { restoreFromKeypress(keyEvent, 1); break; } case DIGIT2: { restoreFromKeypress(keyEvent, 2); break; } case DIGIT3: { restoreFromKeypress(keyEvent, 3); break; } case DIGIT4: { restoreFromKeypress(keyEvent, 4); break; } case DIGIT5: { restoreFromKeypress(keyEvent, 5); break; } case DIGIT6: { restoreFromKeypress(keyEvent, 6); break; } case DIGIT7: { restoreFromKeypress(keyEvent, 7); break; } case DIGIT8: { restoreFromKeypress(keyEvent, 8); break; } case DIGIT9: { restoreFromKeypress(keyEvent, 9); break; } default: break; } } }); publicationData.setWrapText(true); publishScript.getToggles().get(0).setUserData(null); //paneStatus.setVisibility(PaneVisibilityStatus.NOT_VISIBLE); }
From source file:com.core.meka.SOMController.java
private void initListeners() { entradas_text.textProperty().addListener(new ChangeListener<String>() { @Override/*from w w w .j a v a 2 s . co m*/ public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (!newValue.matches("\\d*")) { entradas_text.setText(newValue.replaceAll("[^\\d]", "")); } } }); epocas_text.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (!newValue.matches("\\d*")) { epocas_text.setText(newValue.replaceAll("[^\\d]", "")); } } }); neuronas_text.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (!newValue.matches("\\d*")) { neuronas_text.setText(newValue.replaceAll("[^\\d]", "")); } } }); pesos_check.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { pesos_label.setVisible(true); pesos_text.setVisible(true); } else { pesos_label.setVisible(false); pesos_text.setVisible(false); } } }); base.setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode().equals(KeyCode.ESCAPE)) { Util.closeWindow(ac); } } }); cargar_patrones_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { String patrones = cargarArrayDesdeArchivo(); patrones_train_text.setText(patrones); } catch (IOException ex) { Logger.getLogger(SOMController.class.getName()).log(Level.SEVERE, null, ex); result_text.setText("Excepcion capturada, verifique la pila: \n" + ex.getMessage()); } } }); cargar_pesos_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { String patrones = cargarArrayDesdeArchivo(); pesos_text.setText(patrones); } catch (IOException ex) { Logger.getLogger(SOMController.class.getName()).log(Level.SEVERE, null, ex); result_text.setText("Excepcion capturada, verifique la pila: \n" + ex.getMessage()); } } }); patrones_test_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { String patrones = cargarArrayDesdeArchivo(); patrones_test_text.setText(patrones); } catch (IOException ex) { Logger.getLogger(SOMController.class.getName()).log(Level.SEVERE, null, ex); result_text.setText("Excepcion capturada, verifique la pila: \n" + ex.getMessage()); } } }); nueva_simulacion_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { borrar(neuronas_text, epocas_text, entradas_text); borrar(patrones_train_text, pesos_text); } }); ejecutar_entrenamiento_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { tab.getSelectionModel().select(train_tab); train(); } }); ejecutar_test_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { test(); } }); guardar_patrones_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { String patrones = formatArray(patrones_train_text.getText()); tab.getSelectionModel().selectFirst(); try { guardarArrayAArchivo(patrones.replaceAll(";", ";\n"), result_text); } catch (IOException ex) { result_text.setText("Excepcion capturada:\n" + ex.getMessage().replaceAll("\\)", "\\)\n") + result_text.getText()); Logger.getLogger(SOMController.class.getName()).log(Level.SEVERE, null, ex); } } }); guardar_pesos_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { String patrones = formatArray(pesos_text.getText()); tab.getSelectionModel().selectFirst(); try { guardarArrayAArchivo(patrones.replaceAll(";", ";\n"), result_text); } catch (IOException ex) { result_text.setText("Excepcion capturada:\n" + ex.getMessage().replaceAll("\\)", "\\)\n") + result_text.getText()); Logger.getLogger(SOMController.class.getName()).log(Level.SEVERE, null, ex); } } }); guardar_patrones_test_menuitem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { String patrones = formatArray(patrones_test_text.getText()); tab.getSelectionModel().selectFirst(); try { guardarArrayAArchivo(patrones.replaceAll(";", ";\n"), result_text); } catch (IOException ex) { result_text.setText("Excepcion capturada:\n" + ex.getMessage().replaceAll("\\)", "\\)\n") + result_text.getText()); Logger.getLogger(SOMController.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:account.management.controller.NewVoucherController.java
@Override public void initialize(URL url, ResourceBundle rb) { Platform.runLater(() -> {/* ww w . j a v a 2s .c o m*/ onAddNewFieldButtonClick(null); }); account_list = FXCollections.observableArrayList(); filter_party_rec = FXCollections.observableArrayList(); filter_party_pay = FXCollections.observableArrayList(); new AutoCompleteComboBoxListener<>(select_voucher_type); select_voucher_type.setOnHiding((e) -> { VoucherType a = select_voucher_type.getSelectionModel().getSelectedItem(); select_voucher_type.setEditable(false); select_voucher_type.getSelectionModel().select(a); }); select_voucher_type.setOnShowing((e) -> { select_voucher_type.setEditable(true); }); new AutoCompleteComboBoxListener<>(select_location); select_location.setOnHiding((e) -> { Location a = select_location.getSelectionModel().getSelectedItem(); select_location.setEditable(false); select_location.getSelectionModel().select(a); }); select_location.setOnShowing((e) -> { select_location.setEditable(true); }); new AutoCompleteComboBoxListener<>(select_type); select_type.setOnHiding((e) -> { Project a = select_type.getSelectionModel().getSelectedItem(); select_type.setEditable(false); select_type.getSelectionModel().select(a); }); select_type.setOnShowing((e) -> { select_type.setEditable(true); }); new Thread(() -> { try { Thread.sleep(5000); this.button_submit.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(final KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { System.out.println("attempting to submit new voucher"); //Stop letting it do anything else keyEvent.consume(); onSubmitButtonClick(null); } } }); } catch (InterruptedException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } }).start(); /* * voucher type */ new Thread(() -> { try { HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/voucher/type").asJson(); JSONArray type = res.getBody().getArray(); for (int i = 0; i < type.length(); i++) { JSONObject obj = type.getJSONObject(i); int id = Integer.parseInt(obj.get("id").toString()); String name = obj.get("type_name").toString(); String note = obj.get("details").toString(); this.select_voucher_type.getItems().add(new VoucherType(id, name, note)); } } catch (UnirestException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } }).start(); /* * init locations in select_location combobox */ locations = FXCollections.observableArrayList(); new Thread(() -> { try { HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/locations").asJson(); JSONArray location_array = response.getBody().getArray(); for (int i = 0; i < location_array.length() - 1; i++) { String name = location_array.getJSONObject(i).getString("name"); String details = location_array.getJSONObject(i).getString("details"); int id = location_array.getJSONObject(i).getInt("id"); locations.add(new Location(id, name, details)); } select_location.getItems().addAll(locations); } catch (UnirestException ex) { System.out.println("exception in UNIREST"); } }).start(); this.button_submit.setDisable(true); field_container.setOnKeyReleased((KeyEvent event) -> { validateFields(); }); ToggleGroup tg = new ToggleGroup(); this.project.setToggleGroup(tg); this.lc.setToggleGroup(tg); this.cnf.setToggleGroup(tg); /* * init account name */ new Thread(() -> { final ComboBox<Account> a = (ComboBox<Account>) this.field_row.getChildren().get(0); try { HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/accounts").asJson(); JSONArray account = response.getBody().getArray(); for (int i = 1; i < account.length(); i++) { JSONObject obj = account.getJSONObject(i); int id = Integer.parseInt(obj.get("id").toString()); String name = obj.get("name").toString(); String desc = obj.get("description").toString(); int parent_id = Integer.parseInt(obj.get("parent").toString()); account_list .add(new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString())); if (parent_id == 21) { this.filter_party_rec.add( new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString())); } if (parent_id == 34) { this.filter_party_pay.add( new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString())); } } a.getItems().addAll(account_list); } catch (UnirestException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } finally { new AutoCompleteComboBoxListener<>(a); a.setOnHiding((e) -> { Account acc = a.getSelectionModel().getSelectedItem(); a.setEditable(false); a.getSelectionModel().select(acc); }); a.setOnShowing((e) -> { a.setEditable(true); }); a.setOnAction((e) -> { if (!a.getSelectionModel().isEmpty() && a.getSelectionModel().getSelectedItem().getId() == 21) { a.setPromptText("Select Party"); a.getItems().clear(); a.getItems().addAll(this.filter_party_rec); } if (!a.getSelectionModel().isEmpty() && a.getSelectionModel().getSelectedItem().getId() == 34) { a.getItems().clear(); a.getItems().addAll(this.filter_party_pay); a.setPromptText("Select Party"); } }); } }).start(); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblTerms_OnKeyPressed(KeyEvent keyEvent) { if (keyEvent.isControlDown()) { // LOG.debug("keyEvent.getCharacter(): " + keyEvent.getCharacter()); // LOG.debug("keyEvent.getCode().getName(): " + keyEvent.getCode().getName()); if (keyEvent.getCode().getName().equals("C")) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); Term term = tblTerms.getSelectionModel().getSelectedItem(); content.putString(term.getText()); clipboard.setContent(content); }/* w ww. j a va 2 s .c o m*/ } else if (keyEvent.getCode().getName().equalsIgnoreCase("M")) { this.markTerm(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("E")) { this.doExpansions(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("B")) { this.doBack(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("F")) { this.doForward(); } }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleChartKeyPressed(KeyEvent e) { final KeyCode key = e.getCode(); switch (key) { case RIGHT:/*from ww w. j a v a 2 s .c o m*/ handleNextScan(e); e.consume(); break; case LEFT: handlePreviousScan(e); e.consume(); break; case F: handleZoomOut(e); e.consume(); break; case M: handleManualZoom(e); e.consume(); break; case S: handleSetupLayers(e); e.consume(); break; default: } }
From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java
public void initialize(URL location, ResourceBundle resources) { timeBasedFilter = new TimeBasedKeyEventFilter(500); publicationTopicText.setItems(publicationTopics); formatGroup.getToggles().get(0).setUserData(ConversionMethod.PLAIN); formatGroup.getToggles().get(1).setUserData(ConversionMethod.HEX_DECODE); formatGroup.getToggles().get(2).setUserData(ConversionMethod.BASE_64_DECODE); formatGroup.selectToggle(formatGroup.getToggles().get(0)); formatGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override//from w ww. j a v a 2 s .co m public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { // If plain has been selected if (newValue != null) { switch ((ConversionMethod) formatGroup.getSelectedToggle().getUserData()) { case BASE_64_DECODE: showAsBase64(); break; case HEX_DECODE: showAsHex(); break; case PLAIN: showAsPlain(); break; default: break; } } } }); publicationTopicText.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { switch (keyEvent.getCode()) { case ENTER: { if (connected && timeBasedFilter.processEvent(keyEvent)) { publish(); keyEvent.consume(); } break; } case DIGIT0: { restoreFromKeypress(keyEvent, 0); break; } case DIGIT1: { restoreFromKeypress(keyEvent, 1); break; } case DIGIT2: { restoreFromKeypress(keyEvent, 2); break; } case DIGIT3: { restoreFromKeypress(keyEvent, 3); break; } case DIGIT4: { restoreFromKeypress(keyEvent, 4); break; } case DIGIT5: { restoreFromKeypress(keyEvent, 5); break; } case DIGIT6: { restoreFromKeypress(keyEvent, 6); break; } case DIGIT7: { restoreFromKeypress(keyEvent, 7); break; } case DIGIT8: { restoreFromKeypress(keyEvent, 8); break; } case DIGIT9: { restoreFromKeypress(keyEvent, 9); break; } default: break; } } }); publicationData.setWrapText(true); publicationData.setOnKeyReleased(new EventHandler<Event>() { @Override public void handle(Event event) { final BaseMqttMessage values = readMessage(false, true); String payload = ""; if (values != null) { payload = values.getPayload(); } MqttMessageController.populatePayloadLength(lengthLabel, null, payload.length()); lengthLabel.getStyleClass().removeAll("newLinesPresent", "noNewLines"); if (payload.contains(ConversionUtils.LINE_SEPARATOR_LINUX) || payload.contains(ConversionUtils.LINE_SEPARATOR_WIN) || payload.contains(ConversionUtils.LINE_SEPARATOR_MAC)) { lengthLabel.getStyleClass().add("newLinesPresent"); } else { lengthLabel.getStyleClass().add("noNewLines"); } } }); publishScript.getToggles().get(0).setUserData(null); publishScript.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { if (newValue.getUserData() == null) { publishButton.setText("Publish"); } else { publishButton.setText( "Publish" + System.lineSeparator() + "with" + System.lineSeparator() + "script"); } } }); publishButton.setTooltip( new Tooltip("Publish message [" + MqttViewManager.newPublication.getDisplayText() + "]")); }