private ScrollPane allGlyphs() { List<SVGGlyph> glyphs = SVGGlyphLoader.getAllGlyphsIDs() .stream() .map(glyphName -> { try { return SVGGlyphLoader.getIcoMoonGlyph(glyphName); } catch (Exception e) { return null; } }) .collect(Collectors.toList()); glyphs.sort(Comparator.comparing(SVGGlyph::getName)); glyphs.forEach(glyph -> glyph.setSize(16)); List<Button> iconButtons = glyphs.stream().map(this::createIconButton).collect(Collectors.toList()); // important to improve the performance of animation in scroll pane so buttons are treated as images iconButtons.forEach(button -> button.setCache(true)); Platform.runLater(()->iconButtons.get(0).fire()); FlowPane glyphLayout = new FlowPane(); glyphLayout.setHgap(10); glyphLayout.setVgap(10); glyphLayout.setPadding(new Insets(10)); glyphLayout.getChildren().setAll(iconButtons); glyphLayout.setPrefSize(600, 300); ScrollPane scrollableGlyphs = new ScrollPane(glyphLayout); scrollableGlyphs.setFitToWidth(true); return scrollableGlyphs; }
@Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { if (!startButton.isDisabled()) { startButton.fire(); } } } };
/** * animate this wizard for testing purposes * * @param showTime * @throws Exception */ public void animate(int showTime) throws Exception { int pageTime = showTime / this.pages.size(); for (WizardPane page : this.pages) { if (page instanceof JFXWizardPane) { JFXWizardPane jfxpage = (JFXWizardPane) page; if (jfxpage.selector != null) { animateSelections(jfxpage.selector, pageTime); } else { Thread.sleep(pageTime); } ButtonType buttonType = ButtonType.NEXT; if (jfxpage.getStep() == jfxpage.getSteps()) { buttonType = ButtonType.FINISH; } final ButtonType buttonToClick = buttonType; Platform.runLater(() -> jfxpage.findButton(buttonToClick).fire()); } } }
@Override public void fire() { if (!isFocusTraversable() && !isCancelButton()) { /* * If the button is not focus traversable, it will not receive the focus when clicked. * As a consequence, an opposite FxComponent will not lose its focus which in turn * means, that the model is not updated. If the action handler of this button * depends on it, it will not see the last user's input. * In such cases we must perform the model update explicitly before firering the event. */ Node node = getScene().getFocusOwner(); if (node instanceof FxComponent) { FxUtilities.getInstance().focusLost((FxComponent) node); } } super.fire(); }
nodeChooser.doubleClick().addListener((observable, oldValue, newValue) -> { if (Boolean.TRUE.equals(newValue)) { button.fire();