private void showAutocompletePopup(int insertionIndex, String input) { CompletionResultSource suggestionMaker = mySuggestionProvider.get(); List<MenuItem> suggestions = suggestionMaker.getSortedMatches(input, 5) .map(result -> { Label entryLabel = new Label(); entryLabel.setGraphic(result.getTextFlow()); entryLabel.setPrefHeight(5); CustomMenuItem item = new CustomMenuItem(entryLabel, true); item.setUserData(result); item.setOnAction(e -> applySuggestion(insertionIndex, input, result.getNodeName())); return item; }) .collect(Collectors.toList()); autoCompletePopup.getItems().setAll(suggestions); myCodeArea.getCharacterBoundsOnScreen(insertionIndex, insertionIndex + input.length()) .ifPresent(bounds -> autoCompletePopup.show(myCodeArea, bounds.getMinX(), bounds.getMaxY())); Skin<?> skin = autoCompletePopup.getSkin(); if (skin != null) { Node fstItem = skin.getNode().lookup(".menu-item"); if (fstItem != null) { fstItem.requestFocus(); } } }
this.colorPicker = colorPicker; colorPickerGrid = new JFXColorGrid(); colorPickerGrid.getChildren().get(0).requestFocus(); customColorLabel.setAlignment(Pos.CENTER_LEFT); customColorLink.setPrefWidth(colorPickerGrid.prefWidth(-1));
@Override public RNode<T> focus() { node.requestFocus(); return this; }
mainScene.addEventFilter(KeyEvent.KEY_PRESSED, (event) -> { if(event.getCode().equals(KeyCode.TAB)){ event.consume(); final Node node = mainScene.lookup("#field"+focusNumber); if(node!=null){ node.requestFocus(); } focusNumber ++; if(focusNumber>11){ focusNumber=1; } } });
// The current focus owner on the Scene Node focusOwner = scene.getFocusOwner(); table.requestFocus(); table.requestLayout(); // Request focus on the currently focused Node if(focusOwner != null) focusOwner.requestFocus(); else // request focus on any Node you want textField.requestFocus();
area.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (kc.match(event)) { int ind = vBox.getChildren().indexOf(area); Node next = vBox.getChildren().get(ind + 1); next.requestFocus(); event.consume(); } } });
ChoiceDialog<String> choiceDialog = new ChoiceDialog<>("test", getData()); choiceDialog.showingProperty().addListener((ov, b, b1) -> { if (b1) { choiceDialog.setContentText(""); }else { choiceDialog.setContentText(null); } //or if (b1) { Node comboBox = choiceDialog.getDialogPane().lookup(".combo-box"); comboBox.requestFocus(); } });
public void focusPrevious(Node current) { int index = getChildren().indexOf(current); if (index > 0) { Node previous = getChildren().get(index - 1); previous.requestFocus(); } }
private void validateButton( ButtonType buttonType, BooleanSupplier condition) { Button btn = (Button)dialog.getDialogPane().lookupButton(buttonType); if ( btn != null ) { Node focusOwner = (btn.getScene() != null) ? btn.getScene().getFocusOwner() : null; btn.setDisable(condition.getAsBoolean()); if(focusOwner != null) { focusOwner.requestFocus(); } } }
public Node apply(MultiSelect<E> multiSelect, E item) { SplitMenuButton button = new SplitMenuButton(); button.setText(multiSelect.getConverter().toString(item)); MenuItem remove = new MenuItem(String.format("Remove %s", item)); remove.setOnAction(event -> { int index = multiSelect.getChildrenUnmodifiable().indexOf(button); multiSelect.getItems().remove(item); multiSelect.getChildrenUnmodifiable().get(index).requestFocus(); }); button.getItems().add(remove); button.addEventFilter(KeyEvent.KEY_PRESSED, event -> { if (event.getCode() == KeyCode.BACK_SPACE) remove.getOnAction().handle(null); }); return button; } }
if (currentFocusOwner == null || !isFocusInDockable(newValue.getDockable(), currentFocusOwner)) { LOG.debug("Request focus for new active Dockable: '{}'!", newValue.getDockableData().getTitle()); newValue.getDockable().requestFocus();
@Override public void run() { node.requestFocus();
@Override public void handle(KeyEvent event) { if (KeyCode.TAB.equals(event.getCode())) { if (lowThumb.isFocused()) { if (event.isShiftDown()) { lowThumb.setFocus(false); new ParentTraversalEngine( rangeSlider.getScene().getRoot(), algorithm) .select(lowThumb, Direction.PREVIOUS) .requestFocus(); } else { lowThumb.setFocus(false); highThumb.setFocus(true); } event.consume(); } else if (highThumb.isFocused()) { if(event.isShiftDown()) { highThumb.setFocus(false); lowThumb.setFocus(true); } else { highThumb.setFocus(false); new ParentTraversalEngine( rangeSlider.getScene().getRoot(), algorithm) .select(highThumb, Direction.NEXT) .requestFocus(); } event.consume(); } } } };
nextFocusedNode.requestFocus();
newValue.getAdapted().getDockable().requestFocus();
newValue.getAdapted().getDockable().requestFocus();
this.colorPicker = colorPicker; colorPickerGrid = new JFXColorGrid(); colorPickerGrid.getChildren().get(0).requestFocus(); customColorLabel.setAlignment(Pos.CENTER_LEFT); customColorLink.setPrefWidth(colorPickerGrid.prefWidth(-1));