public void start(Stage primaryStage, ScrollPane rootLayout) throws Exception { primaryStage.setTitle("Change Hotkeys"); Scene myScene = new Scene(rootLayout); ourStage = primaryStage; myScene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { public void handle(KeyEvent event) { if (changeHotkey) { if (addHotkey(event, changeHotkeyFunction)) { changeHotkey = false; } } } }); Label divider = new Label(); HBox labelHbox = new HBox(divider); divider.setText("----These hotkeys are not changeable----"); labelHbox.setAlignment(Pos.CENTER); for (String key : HOTKEYS) { hotkeyVBox.getChildren().add(hotkeys.get(key).getHotkeyHBox()); } hotkeyVBox.getChildren().add(labelHbox); for (ImmutableHotkey hotkey : IMMUTABLE_HOTKEYS) { hotkeyVBox.getChildren().add(hotkey.getHotkeyHBox()); } primaryStage.setScene(myScene); }
@FXML public void openHelp(ActionEvent event) throws IOException { Parent root = FXMLLoader.load(getClass().getResource("/fxml/helpPopup.fxml")); final Scene scene = new Scene(root); final Stage stage = new Stage(); stage.setTitle("Help"); stage.setScene(scene); stage.show(); stage.setResizable(false); stage.centerOnScreen(); root.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ESCAPE) { System.out.println("Key Pressed: " + ke.getCode()); stage.close(); } } }); }
/** * Updating rotation. */ @FXThread private void updateRotation(@Nullable final KeyEvent event) { if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return; final Quaternion oldValue = notNull(getPropertyValue()); final FloatTextField xField = getXField(); final float x = degreeToRadians(xField.getValue()); final FloatTextField yFiled = getYFiled(); final float y = degreeToRadians(yFiled.getValue()); final FloatTextField zField = getZField(); final float z = degreeToRadians(zField.getValue()); final Quaternion newValue = new Quaternion(); newValue.fromAngles(ArrayFactory.toFloatArray(x, y, z)); changed(newValue, oldValue.clone()); }
@FXML public void openCreditsAction(ActionEvent event) throws IOException { Node node = (Node) event.getSource(); final Stage stage = (Stage) node.getScene().getWindow(); Parent root = FXMLLoader.load(getClass().getResource("/fxml/Credits.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); final Scene hScene = new Scene(home); root.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ESCAPE) { System.out.println("Key Pressed: " + ke.getCode()); stage.setScene(hScene); } } }); }
protected void enterAction(KeyEvent event) { event.consume(); if (functionText.length() > 0) { String function = functionText.toString(); append(">> ", promptStyle); append(function, inputStyle); inputJoin.send(Channel.LINE, function); } else { String text = area.getText(); append(">> ", promptStyle); append(text, inputStyle); append("\n", inputStyle); String line = getLine(); inputJoin.send(Channel.LINE, line); } functionText = new StringBuffer(); area.clear(); }
private void onKeyPressed(KeyEvent event) { if (event.getCode() == KeyCode.ESCAPE) { handleSelection(Selection.CANCEL); } else if (event.getCode() == KeyCode.ENTER) { Node focusOwner = root.getScene().getFocusOwner(); if (focusOwner instanceof Button) { ((Button) (focusOwner)).fire(); } } }
public static String ketEventGetModifiersExText(KeyEvent event) { StringBuffer sb = new StringBuffer(); if (event.isControlDown()) { sb.append("Ctrl+"); } if (event.isMetaDown()) { sb.append("Meta+"); } if (event.isAltDown()) { sb.append("Alt+"); } if (event.isShiftDown()) { sb.append("Shift+"); } String text = sb.toString(); if (text.equals("")) { return text; } return text.substring(0, text.length() - 1); }
private void sendKey(Node node, char c) { node = getActiveNode(node); JavaAgentKeys keys = JavaAgentKeys.getKeyFromUnicode(c); if (keys == null) { dispatchKeyEvent(node, null, KeyEvent.KEY_PRESSED, c); if (deviceState.getModifierEx() == 0) { dispatchKeyEvent(node, null, KeyEvent.KEY_TYPED, c); } dispatchKeyEvent(node, null, KeyEvent.KEY_RELEASED, c); return; } if (keys == JavaAgentKeys.NULL) { resetModifierState(node); } else if (deviceState.isModifier(keys)) { pressKey(node, keys); } else { pressKey(node, keys); if (keys == JavaAgentKeys.SPACE) { dispatchKeyEvent(node, null, KeyEvent.KEY_TYPED, ' '); } releaseKey(node, keys); } }
private static String checkModifier(KeyEvent e) { String s = ""; if (e.isShiftDown()) { s = "Shift"; } if (e.isControlDown()) { s = "Ctrl"; } if (e.isAltDown()) { s = "Alt"; } if (e.isMetaDown()) { s = "Meta"; } return s; }
/** * Adds an auto-completion to a certain argument - Must be added in decreasing order * @param index Arg index * @param completion Completion type */ @SuppressWarnings("deprecation") protected void setArgCompletion(int index, TabCompletion completion) { completions.put(index, completion); Nodes.TEXTFIELD.addEventHandler(KeyEvent.KEY_RELEASED, e -> { if(e.getCode() == KeyCode.TAB) { String t = Nodes.TEXTFIELD.getText() + "\0"; String[] args = Formatter.getInstance().format(t).split(" "); if(args.length == 1 && args[0].replace("\0", "").isEmpty() && completion instanceof InitialCommandTabCompletion) { completion.onTab(new String[] {""}); } else if(args.length > 0 && (args[0].equals(name) || args.length == 1)) { if(args.length == index + 2) { List<String> list = Arrays.asList(args); list.set(list.size()-1, list.get(list.size()-1).replace("\0", "")); completion.onTab(list.toArray(new String[list.size()])); } } } }); }
private String buildModifiersText(KeyEvent e) { StringBuilder sb = new StringBuilder(); if (e.isAltDown()) { sb.append("Alt+"); } if (e.isControlDown()) { sb.append("Ctrl+"); } if (e.isMetaDown()) { sb.append("Meta+"); } if (e.isShiftDown()) { sb.append("Shift+"); } if (sb.length() > 0) { sb.setLength(sb.length() - 1); } String mtext = sb.toString(); return mtext; }
@FXML public void openStatisticsAction(ActionEvent event) throws IOException { Node node = (Node) event.getSource(); final Stage stage = (Stage) node.getScene().getWindow(); Parent root = FXMLLoader.load(getClass().getResource("/fxml/Statistics.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); final Scene hScene = new Scene(home); root.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ESCAPE) { System.out.println("Key Pressed: " + ke.getCode()); stage.setScene(hScene); } } }); }
private boolean isContextMenuKeyEvent(KeyEvent event) { if (!event.getEventType().equals(KeyEvent.KEY_PRESSED)) { return false; } if (event.getCode() == KeyCode.CONTROL || event.getCode() == KeyCode.SHIFT || event.getCode() == KeyCode.ALT || event.getCode() == KeyCode.META) { return false; } String keyText = isModifiers(event) ? ketEventGetModifiersExText(event) + "+" : ""; keyText += keyEventGetKeyText(event.getCode()); StringBuffer contextMenuText = new StringBuffer(); if (keyModifiers != null && !keyModifiers.equals("")) { contextMenuText.append(keyModifiers + "+"); } contextMenuText.append(key); return contextMenuText.toString().equals(keyText); }
@FXML private void emailcheck(KeyEvent k) { String c=k.getCharacter(); if(c.equals(" ")) { k.consume(); } String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$"; if(userNameTF.getText().matches(EMAIL_REGEX)) { validateFalseLabel.setVisible(false); validateTrueLabel.setVisible(true); validateTrueLabel.setText("Kindly click on Login"); b=true; } else { validateTrueLabel.setVisible(false); validateFalseLabel.setVisible(true); validateFalseLabel.setText("Invalid E-Mail Format"); b=false; } }
private void setUpListener (Scene scene, Pane pane) { pane.requestFocus(); pane.setOnMouseClicked(e -> queue(myEventFactory.interpretEvent(e, myScale.getScale(), myScale.getScale()))); scene.addEventFilter(KeyEvent.KEY_RELEASED, e -> queue(myEventFactory.interpretEvent(e))); scene.addEventFilter(KeyEvent.KEY_PRESSED, e -> queue(myEventFactory.interpretEvent(e))); }
public Thumb2CodeArea() { getStylesheets().clear(); getStylesheets().add(Thumb2CodeArea.class.getClassLoader() .getResource("styles/thumb2-syntax-highlight.css").toExternalForm()); getStylesheets().add(Thumb2CodeArea.class.getClassLoader() .getResource("styles/spellchecking.css").toExternalForm()); setCursor(Cursor.TEXT); richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) .subscribe(change -> { SyntaxHighlighter syntaxHighlighter = new SyntaxHighlighter(); setStyleSpans(0, syntaxHighlighter.highlight(getText())); }); addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent e) -> { if(e.getCode() == KeyCode.TAB) { String s = " "; insertText(getCaretPosition(), s); e.consume(); } }); }
@Override public void start(Stage rootStage) throws Exception { rootStage.setMaximized(true); main = this; FXMLLoader loader = new FXMLLoader(getClass().getResource("/resources/layouts/main.fxml")); Parent root = loader.load(); Scene rootScene = new Scene(root); rootStage.setTitle("Parallator"); rootController = loader.getController(); rootStage.setScene(rootScene); initMenu(rootStage); rootStage.show(); rootStage.setOnCloseRequest(event -> { if (rootController.getFile() == null || !rootController.isEdited()) return; Alert alert = new Alert(Alert.AlertType.WARNING); alert.setHeaderText("Сохранить перед выходом?"); alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); Optional<ButtonType> result = alert.showAndWait(); if (result.isPresent() && result.get() == ButtonType.YES) { rootController.save(); } if (result.isPresent() && result.get() == ButtonType.CANCEL) { event.consume(); } }); rootScene.addEventFilter(KeyEvent.KEY_PRESSED, event -> { switch (event.getCode()) { case DOWN: rootController.down(); break; case UP: rootController.up(); break; } }); if (MainConfig.getMainConfig().path() != null) rootController.open(new File(MainConfig.getMainConfig().path())); }
/** * Builds the window and add events. * @throws IOException */ public NewTaskListWindow() throws IOException { super(); FXMLLoader fxmlLoader = new FXMLLoader( getClass().getResource("/FXML/newTaskList.fxml")); Parent root = (Parent) fxmlLoader.load(); taskListController = (NewTaskListController) fxmlLoader.getController(); Scene scene = new Scene(root); setScene(scene); setResizable(false); initStyle(StageStyle.TRANSPARENT); this.wantsToAdd = false; //After pressing 'Enter', closes this window (which returns the value) scene.setOnKeyPressed((final KeyEvent keyEvent) -> { if (keyEvent.getCode() == KeyCode.ENTER) { this.wantsToAdd = true; this.close(); } else if (keyEvent.getCode() == KeyCode.ESCAPE) { this.close(); } }); //Not focusing the window means closing it focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (!isNowFocused) { close(); } }); }
/** * * @author shabier */ @FXML public void openHome(ActionEvent event) throws IOException { // MyJDBC.createTestDatabase("shabo"); Node node = (Node) event.getSource(); final Stage stage = (Stage) node.getScene().getWindow(); Parent root = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); stage.centerOnScreen(); final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); final Scene hScene = new Scene(home); root.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ESCAPE) { System.out.println("Key Pressed: " + ke.getCode() + " Made by ShaMaster"); stage.setScene(hScene); } } }); }
public void getKeyTyped(KeyEvent keyEvent) { if ("\b".equals(keyEvent.getCharacter()) && !searchText.isEmpty()) { searchText = searchText.substring(0, searchText.length() - 1); } else { if (!keyEvent.getCharacter().contains("\\")) { searchText += keyEvent.getCharacter(); } } System.out.println(searchText); if (!searchText.isEmpty()) { List<SearchedResult> searchedResults = getSearchResult(searchText, searchField); showTableData(searchedResults); } else { tview.getItems().clear(); } }
/** * * @param event */ private void keyPressedOnApp(KeyEvent event) { Direction direction = new Direction(event.getCode()); switch (direction.getKey()) { case UP: this.keyPressedAnimation(this.UP); this.move(direction); break; case DOWN: this.keyPressedAnimation(this.DOWN); this.move(direction); break; case LEFT: this.keyPressedAnimation(this.LEFT); this.move(direction); break; case RIGHT: this.keyPressedAnimation(this.RIGHT); this.move(direction); break; default: break; } }
@Override public void start(Stage stage) throws Exception { VBox root = new VBox(); root.setMinSize(200, 100); Label typedTextLabel = new Label(""); root.getChildren().addAll(typedTextLabel); Scene scene = new Scene(root); // Multicast typed keys Observable<String> typedLetters = JavaFxObservable.eventsOf(scene, KeyEvent.KEY_TYPED) .map(KeyEvent::getCharacter) .share(); // Signal 300 milliseconds of inactivity Observable<String> restSignal = typedLetters .throttleWithTimeout(500, TimeUnit.MILLISECONDS) .startWith(""); //trigger initial // switchMap() each period of inactivity to // an infinite scan() concatenating typed letters restSignal.switchMap(s -> typedLetters.scan("", (rolling, next) -> rolling + next) ).observeOn(JavaFxScheduler.platform()) .subscribe(s -> { typedTextLabel.setText(s); System.out.println(s); }); stage.setScene(scene); stage.show(); }
@FXML void btnBuscar_onKeyPressed(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { if (txtNomeSoftware.getText().equals("")) { preencherTableViewRequisitos(software.buscarTodosSoftwares()); } else { preencherTableViewRequisitos(software.buscarPorNome(txtNomeSoftware.getText())); } } }
@Override public void handle(KeyEvent event) { if(treeViewTraverser == null) { return; } switch(event.getCode()) { case UP: label.setText(treeViewTraverser.stepBackward()); break; case DOWN: label.setText(treeViewTraverser.stepForward()); break; case LEFT: label.setText(treeViewTraverser.stepOut()); break; case RIGHT: label.setText(treeViewTraverser.stepIn()); break; } }
private void editNameMode() { TextField t = new TextField(); t.setMaxWidth(180); t.setText(moment.getNom()); t.requestFocus(); ChangeListener<Boolean> listener = new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) { if (!newPropertyValue) { RenameMomentCommand cmd = new RenameMomentCommand(nameController,moment.getNom(),t.getText()); cmd.execute(); UndoCollector.INSTANCE.add(cmd); borderPaneLabel.setCenter(label); t.focusedProperty().removeListener(this); } } }; t.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if(event.getCode() == KeyCode.ENTER){ t.setText(t.getText()); borderPaneLabel.setCenter(label); } if(event.getCode() == KeyCode.ESCAPE){ borderPaneLabel.setCenter(label); } } }); t.focusedProperty().addListener(listener); Platform.runLater(()->t.requestFocus()); Platform.runLater(()->t.selectAll()); borderPaneLabel.setCenter(t); }
/** * When user finished editing the node id {@link TextField}. * * @param keyEvent the {@link KeyEvent} */ @FXML void setNodeId(final KeyEvent keyEvent) { settings.addRunnable(() -> { final TextField source = (TextField) keyEvent.getSource(); final int newValue = Integer.parseInt(source.getText().replaceAll("[^\\d]", "")); graphDimensionsCalculator.getViewPointProperty() .set(graphDimensionsCalculator.getGraphProperty().get().getRealStartXPosition(newValue)); }); }
@FXML public void openSubmitAction(ActionEvent event) throws IOException { Node node = (Node) event.getSource(); final Stage stage = (Stage) node.getScene().getWindow(); Parent root = FXMLLoader.load(getClass().getResource("/fxml/Submit.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); final Scene hScene = new Scene(home); root.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ESCAPE) { System.out.println("Key Pressed: " + ke.getCode()); stage.setScene(hScene); } } }); }
@Override public void handle(KeyEvent event) { String code = event.getCode().getName().toLowerCase(); if(event.getEventType()==KeyEvent.KEY_PRESSED){ press.handle(code); }else if(event.getEventType()==KeyEvent.KEY_RELEASED){ release.handle(code); } }
private void filterAltEvents() { EventHandler<KeyEvent> handler = e -> { if(e.isAltDown()) { Event.fireEvent(this.view, e); } }; this.view.getCodeArea().setOnKeyPressed(handler); }
public void searchKeyReleaseEvent() { search_bill.setOnKeyReleased((KeyEvent keyEvent) -> { long bill_no = 0; String date = ""; String whoesaler = ""; float total_amount = 0; ObservableList<Purchase_history> search_bill_data = FXCollections.observableArrayList(); search_bill_table.setItems(search_bill_data); String search = search_bill.getText(); if (search.equals("")) { search_bill_table.setItems(search_bill_table_list); } else { Iterator<Purchase_history> iterator = search_bill_table_list.iterator(); while (iterator.hasNext()) { Purchase_history temp = iterator.next(); bill_no = temp.getSearchBillNo(); if (String.valueOf(bill_no).contains(search)) { whoesaler = temp.getSearchWholesaler(); date = temp.getSearchDate(); total_amount = temp.getSearchAmount(); search_bill_data.add(new Purchase_history(whoesaler,bill_no, date, total_amount)); } } } }); }
private void PushKey(KeyEvent event, MainFormController controller) { final KeyCode code = event.getCode(); switch(code){ case F1: System.err.println("F1_Key_Pushed"); controller.ShufflePanels(); warning.Stop(); break; default: break; } }
private void initUi() { overlay.getStyleClass().add(OVERLAY_STYLE_CLASS); showing.addListener((v, o, n) -> onShowingChanged(n)); mode.addListener((v, o, n) -> onModeChanged(n)); root.addEventHandler(KeyEvent.KEY_PRESSED, this::onKeyPressed); root.visibleProperty().bind(showing); root.managedProperty().bind(showing); overlay.visibleProperty().bind(showing); overlay.managedProperty().bind(showing); leftButton.setOnAction(event -> handleSelection(Selection.SAVE)); middleButton.setOnAction(event -> handleSelection(Selection.CLOSE)); rightButton.setOnAction(event -> handleSelection(Selection.CANCEL)); dialogLabel.setGraphic(Svg.WARNING.node()); }
public LettersPane() { setId("LettersPane"); setPrefSize(480,480); setFocusTraversable(true); setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { requestFocus(); me.consume(); } }); setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { createLetter(ke.getText()); ke.consume(); } }); // create press keys text pressText = new Text("Press Keys"); pressText.setTextOrigin(VPos.TOP); pressText.setFont(new Font(Font.getDefault().getFamily(), 40)); pressText.setLayoutY(5); pressText.setFill(Color.rgb(80, 80, 80)); DropShadow effect = new DropShadow(); effect.setRadius(0); effect.setOffsetY(1); effect.setColor(Color.WHITE); pressText.setEffect(effect); getChildren().add(pressText); }
/** * Initialize the UI for the Main window. */ private void initUI() { setName("DisplayWindow"); setWindowState(); setTheme(); String projectName = System.getProperty(Constants.PROP_PROJECT_NAME, ""); if (projectName.equals("")) { projectName = "Marathon"; } setTitle(projectName); getIcons().add(FXUIUtils.getImageURL("logo16")); getIcons().add(FXUIUtils.getImageURL("logo32")); getIcons().add(FXUIUtils.getImageURL("logo64")); getIcons().add(FXUIUtils.getImageURL("logo128")); getIcons().add(FXUIUtils.getImageURL("logo256")); workspace = new DockingDesktop("Marathon"); workspace.addDockableSelectionListener(dockingListener); workspace.addDockableStateWillChangeListener(dockingListener); workspace.addDockableStateChangeListener(dockingListener); ToolBarContainer container = ToolBarContainer.createDefaultContainer(Orientation.LEFT); createToolBar(container); container.setContent(workspace); BorderPane fxBorderPane = new BorderPane(container); fxBorderPane.setTop(createMenuBar()); fxBorderPane.setBottom(statusPanel); Scene scene = new Scene(fxBorderPane); scene.getStylesheets().add(ModalDialog.class.getClassLoader() .getResource("net/sourceforge/marathon/fx/api/css/marathon.css").toExternalForm()); setScene(scene); initStatusBar(); initDesktop(); addEventFilter(KeyEvent.KEY_PRESSED, (event) -> { if (event.getCode() == KeyCode.F10) setFullScreen(true); }); setExitHook(); }
protected void upAction(KeyEvent event) { event.consume(); if (!readline.getHistory().next()) { currentLine = getLine(); } else { readline.getHistory().previous(); // undo check } if (!readline.getHistory().previous()) { return; } String oldLine = readline.getHistory().current().trim(); replaceText(oldLine); }
/** * Handle the key pressed event. * * @param event the event */ @FXThread protected void processKeyPressed(@NotNull final KeyEvent event) { final KeyCode code = event.getCode(); if (code == KeyCode.S && event.isControlDown() && isDirty()) { save(); } else if (handleKeyActionImpl(code, true, event.isControlDown(), event.isShiftDown(), false)) { event.consume(); } }
/** * Remove autoCompletion listeners from the TextField */ public void removeAutoCompletion() { // TextChanged Listener textField.textProperty().removeListener(textListener); // FocusListener textField.focusedProperty().removeListener(focusListener); //Add keyHandler? textField.removeEventHandler(KeyEvent.KEY_RELEASED, keyHandler); }