/** * Construct a responsive handler for a specified Stage and css class. * <p> * Device css classes can be one of the following: * <ul> * <li>{@link JFXResponsiveHandler#PSEUDO_CLASS_EX_SMALL}</li> * <li>{@link JFXResponsiveHandler#PSEUDO_CLASS_LARGE}</li> * <li>{@link JFXResponsiveHandler#PSEUDO_CLASS_MEDIUM}</li> * <li>{@link JFXResponsiveHandler#PSEUDO_CLASS_SMALL}</li> * </ul> * <p> * <b>Note:</b> the css class must be chosen by the user according to a device * detection methodology * * @param stage the JavaFX Application stage * @param pseudoClass css class for certain device */ public JFXResponsiveHandler(Stage stage, PseudoClass pseudoClass) { scanAllNodes(stage.getScene().getRoot(), pseudoClass); }
@Override public void show() { if (!jfxDatePicker.isOverLay()) { super.show(); } if (content != null) { content.init(); content.clearFocus(); } if (dialog == null && jfxDatePicker.isOverLay()) { StackPane dialogParent = jfxDatePicker.getDialogParent(); if (dialogParent == null) { dialogParent = (StackPane) jfxDatePicker.getScene().getRoot(); } dialog = new JFXDialog(dialogParent, (Region) getPopupContent(), DialogTransition.CENTER, true); arrowButton.setOnMouseClicked((click) -> { if (jfxDatePicker.isOverLay()) { StackPane parent = jfxDatePicker.getDialogParent(); if (parent == null) { parent = (StackPane) jfxDatePicker.getScene().getRoot(); } dialog.show(parent); } }); } }
@Override public void show() { if (!jfxTimePicker.isOverLay()) { super.show(); } if (content != null) { content.init(); content.clearFocus(); } if (dialog == null && jfxTimePicker.isOverLay()) { StackPane dialogParent = jfxTimePicker.getDialogParent(); if (dialogParent == null) { dialogParent = (StackPane) jfxTimePicker.getScene().getRoot(); } dialog = new JFXDialog(dialogParent, (Region) getPopupContent(), DialogTransition.CENTER, true); arrowButton.setOnMouseClicked((click) -> { if (jfxTimePicker.isOverLay()) { StackPane parent = jfxTimePicker.getDialogParent(); if (parent == null) { parent = (StackPane) jfxTimePicker.getScene().getRoot(); } dialog.show(parent); } }); } }
@Override public void start(Stage stage) { JFXSlider horLeftSlider = new JFXSlider(); horLeftSlider.setMinWidth(500); JFXSlider horRightSlider = new JFXSlider(); horRightSlider.setMinWidth(500); horRightSlider.setIndicatorPosition(IndicatorPosition.RIGHT); JFXSlider verLeftSlider = new JFXSlider(); verLeftSlider.setMinHeight(500); verLeftSlider.setOrientation(Orientation.VERTICAL); JFXSlider verRightSlider = new JFXSlider(); verRightSlider.setMinHeight(500); verRightSlider.setOrientation(Orientation.VERTICAL); verRightSlider.setIndicatorPosition(IndicatorPosition.RIGHT); HBox hbox = new HBox(); hbox.setSpacing(450); hbox.getChildren().addAll(verRightSlider, verLeftSlider); VBox vbox = new VBox(); vbox.getChildren().addAll(horRightSlider, horLeftSlider, hbox); vbox.setSpacing(100); vbox.setPadding(new Insets(100, 50, 50, 150)); Scene scene = new Scene(new Group()); ((Group) scene.getRoot()).getChildren().add(vbox); scene.getStylesheets().add(SliderDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setScene(scene); stage.setWidth(900); stage.setHeight(900); stage.show(); stage.setTitle("JFX Slider Demo"); }
@Override public Set<Node> apply( Window input ) { return findAllRecursively(matcher, input.getScene().getRoot()); } } );
@Override public Set<T> apply( Window input ) { return findAllRecursively(predicate, input.getScene().getRoot()); } } );
public static List<Node> getAllNodesInWindow(Window window) { Parent root = Optional.of(window).map(w -> w.getScene()).map(s -> s.getRoot()).get(); if (root == null) { return new ArrayList<>(); } else { List<Node> ret = new ArrayList<>(); ret.add(root); ret.addAll(getAllNodesInParent(root)); return ret; } }
public static List<Node> getAllNodesInWindow(Window window) { Parent root = Optional.of(window).map(w -> w.getScene()).map(s -> s.getRoot()).get(); if (root == null) { return new ArrayList<>(); } else { List<Node> ret = new ArrayList<>(); ret.add(root); ret.addAll(getAllNodesInParent(root)); return ret; } }
/** * save me as a Png File * * @param stage * - the stage to take a screen shot from * @param file * - the file to save the image to */ public static synchronized void saveAsPng(Stage stage, File file) { saveAsPng(stage.getScene().getRoot(), file); }
public static void stripRootPane(Scene scene, Parent originalParent, boolean useReflection) { Parent oldParent = scene.getRoot(); getChildren(oldParent, useReflection).remove(originalParent); originalParent.getStyleClass().remove("root"); //$NON-NLS-1$ scene.setRoot(originalParent); }
/** * Initializes the view. */ private void initView() { if (!initialized) { BorderPane bp = (BorderPane) stage.getScene().getRoot(); root = new StackPane(); bp.setCenter(root); initialized = true; } }
public static void injectAsRootPane(Scene scene, Parent injectedParent, boolean useReflection) { Parent originalParent = scene.getRoot(); scene.setRoot(injectedParent); if (originalParent != null) { getChildren(injectedParent, useReflection).add(0, originalParent); // copy in layout properties, etc, so that the dialogStack displays // properly in (hopefully) whatever layout the owner node is in injectedParent.getProperties().putAll(originalParent.getProperties()); } }
public void updateFeedback(Consumer<StackPane> consumer) { consumer.accept((StackPane) this.popupWindow.getScene().getRoot()); this.popupWindow.sizeToScene(); this.popupWindow.setX(this.screenX - this.popupWindow.getWidth() / 2); this.popupWindow.setY(this.screenY + 20); this.popupWindow.show(); }
private EventHandler<MouseEvent> getDisplaMessageMouseEnterFocusEventHandler(DecoratedText text, String message) { return event -> { final Group viewContainer = (Group) ((StackPane)text.getScene().getRoot()).getChildren().get(1); DisplayMessageOverlayLabel label = new DisplayMessageOverlayLabel(message, sizeing); double y = event.getSceneY(); label.setLayoutY(y); label.setLayoutX(350); // todo: andi 3/8/15: Use some kind of constant. Also consider that the width of the control board may be scalable at one time in the future viewContainer.getChildren().add(label); // Add it to the scene and not the scroll pane and adjust the location }; } private EventHandler<MouseEvent> getDisplayMessageMouseExitFocusEventHandler(DecoratedText text){
public void updateFeedback(Consumer<StackPane> consumer) { consumer.accept((StackPane) this.popupWindow.getScene().getRoot()); this.popupWindow.sizeToScene(); this.popupWindow.setX(this.screenX - this.popupWindow.getWidth() / 2); this.popupWindow.setY(this.screenY + 20); this.popupWindow.show(n.getScene().getWindow()); }
public void start(Stage stage) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Scene scene =new Scene(new Group(),800,600); JdbcDataSource dataSource=new JdbcDataSource("jdbc:mysql://localhost:3306/mybasename?zeroDateTimeBehavior=convertToNull&user=username&password=userpassword", "clients", "descr"); TableView tableView=new TableView(); tableView.setItems(dataSource.getData()); tableView.getColumns().addAll(dataSource.getColumns()); ((Group)scene.getRoot()).getChildren().add(tableView); stage.setScene(scene); stage.show(); }
@Override public void start(Stage stage) { stage.setTitle("CheckBoxCell Samples"); final Scene scene = new Scene(new Group(), 875, 700); scene.setFill(Color.LIGHTGRAY); Group root = (Group) scene.getRoot(); root.getChildren().add(getContent(scene)); AquaFx.style(); stage.setScene(scene); stage.show(); }
private void applicationReady() { FadeTransition ft = new FadeTransition(Duration.millis(500), preloaderStage.getScene().getRoot()); ft.setFromValue(1.0); ft.setToValue(0.0); ft.setOnFinished(e -> { preloaderStage.hide(); }); ft.play(); }
public static void addResizeListener(Stage stage) { ResizeListener resizeListener = new ResizeListener(stage, null); stage.getScene().addEventHandler(MouseEvent.MOUSE_MOVED, resizeListener); stage.getScene().addEventHandler(MouseEvent.MOUSE_PRESSED, resizeListener); stage.getScene().addEventHandler(MouseEvent.MOUSE_DRAGGED, resizeListener); stage.getScene().addEventHandler(MouseEvent.MOUSE_EXITED, resizeListener); stage.getScene().addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, resizeListener); ObservableList<Node> children = stage.getScene().getRoot().getChildrenUnmodifiable(); for (Node child : children) { // addListenerDeeply(child, resizeListener); } }