List of usage examples for javafx.scene.layout StackPane getChildren
@Override
public ObservableList<Node> getChildren()
From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXCombinedChartGestureDemo.java
@Override public void start(Stage stage) throws Exception { try {/*from www . jav a2s . co m*/ JFreeChart chart = createCombinedChart(); EChartViewer canvas = new EChartViewer(chart); StackPane stackPane = new StackPane(); stackPane.getChildren().add(canvas); stage.setScene(new Scene(stackPane)); stage.setTitle("Chart gesture demo"); stage.setWidth(700); stage.setHeight(390); stage.show(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label markerText = new Label(); StackPane.setAlignment(markerText, Pos.TOP_CENTER); String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); final ObservableMap<String, Duration> markers = m.getMarkers(); markers.put("Robot Finds Wall", Duration.millis(3100)); markers.put("Then Finds the Green Line", Duration.millis(5600)); markers.put("Robot Grabs Sled", Duration.millis(8000)); markers.put("And Heads for Home", Duration.millis(11500)); final MediaPlayer mp = new MediaPlayer(m); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override//w w w .j a va2 s . c o m public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { markerText.setText(event.getMarker().getKey()); } }); } }); final MediaView mv = new MediaView(mp); final StackPane root = new StackPane(); root.getChildren().addAll(mv, markerText); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); markerText.setText(""); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 2"); primaryStage.show(); mp.play(); }
From source file:isbnfilter.ISBNFilter.java
@Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override/* ww w .j av a 2s . c o m*/ public void handle(ActionEvent event) { System.out.println("Hello World!"); try { List<String[]> isbns = readFile(primaryStage); //Lee y mete todo en un string ISBNConverter classISBN = new ISBNConverter(); classISBN.createNewFile(isbns); } catch (IOException | JSONException ex) { Logger.getLogger(ISBNFilter.class.getName()).log(Level.SEVERE, null, ex); } } }); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:org.openwms.client.fx.core.view.CustomerDataScreen.java
@SuppressWarnings("unchecked") private Node createDataTable() { StackPane dataTableBorder = new StackPane(); dataTableBorder.getChildren().add(tableView); dataTableBorder.setPadding(new Insets(8)); dataTableBorder.setStyle("-fx-background-color: lightgray"); tableView.setItems(controller.getCustomers()); tableView.getColumns().setAll(TableColumnBuilder.<Customer, String>create().text("First Name") .cellValueFactory(new PropertyValueFactory<Customer, String>("firstName")).prefWidth(204).build(), TableColumnBuilder.<Customer, String>create().text("Last Name") .cellValueFactory(new PropertyValueFactory<Customer, String>("lastName")).prefWidth(204) .build(),//from w w w . j a v a2 s .co m TableColumnBuilder.<Customer, String>create().text("Sign-up Date") .cellValueFactory(new PropertyValueFactory<Customer, String>("signupDate")).prefWidth(351) .build()); tableView.setPrefHeight(500); return dataTableBorder; }
From source file:Main.java
@Override public void start(Stage stage) { Group p = new Group(); Scene scene = new Scene(p); stage.setScene(scene);/*from w w w. j av a 2s. c om*/ stage.setWidth(500); stage.setHeight(500); p.setTranslateX(80); p.setTranslateY(80); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156, 216, 255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text(i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); p.getChildren().add(stack); stage.show(); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //You can add a specific action when each frame is started. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.millis(2000); //one can add a specific action when the keyframe is reached EventHandler onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random() * 200 - 100); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished, keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); timeline.play(); timer.start(); }
From source file:projavafx.videoplayer3.VideoPlayer3.java
@Override public void start(Stage primaryStage) { final Label message = new Label("I \u2764 Robots"); message.setVisible(false);/* w ww .ja v a 2s. co m*/ String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); m.getMarkers().put("Split", Duration.millis(3000)); m.getMarkers().put("Join", Duration.millis(9000)); final MediaPlayer mp = new MediaPlayer(m); final MediaView mv1 = new MediaView(mp); mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540)); StackPane.setAlignment(mv1, Pos.CENTER_LEFT); final MediaView mv2 = new MediaView(mp); mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540)); StackPane.setAlignment(mv2, Pos.CENTER_RIGHT); StackPane root = new StackPane(); root.getChildren().addAll(message, mv1, mv2); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); message.setVisible(false); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 3"); primaryStage.show(); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { if (event.getMarker().getKey().equals("Split")) { message.setVisible(true); buildSplitTransition(mv1, mv2).play(); } else { buildJoinTransition(mv1, mv2).play(); } } }); } }); mp.play(); }
From source file:Main.java
public static void addMarker(final XYChart<?, ?> chart, final StackPane chartWrap) { final Line valueMarker = new Line(); final Node chartArea = chart.lookup(".chart-plot-background"); chartArea.setOnMouseMoved(new EventHandler<MouseEvent>() { @Override/*from ww w . j a va 2 s. c om*/ public void handle(MouseEvent event) { Point2D scenePoint = chart.localToScene(event.getSceneX(), event.getSceneY()); Point2D position = chartWrap.sceneToLocal(scenePoint.getX(), scenePoint.getY()); Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal()); valueMarker.setStartY(0); valueMarker.setEndY(chartWrap.sceneToLocal(chartAreaBounds).getMaxY() - chartWrap.sceneToLocal(chartAreaBounds).getMinY()); valueMarker.setStartX(0); valueMarker.setEndX(0); valueMarker.setTranslateX(position.getX() - chartWrap.getWidth() / 2); double ydelta = chartArea.localToScene(0, 0).getY() - chartWrap.localToScene(0, 0).getY(); valueMarker.setTranslateY(-ydelta * 2); } }); chartWrap.getChildren().add(valueMarker); }
From source file:org.samcrow.frameviewer.App.java
@Override public void start(final Stage stage) { try {//www. j a va 2s. c o m // Check for command-line frame directory File videoFile; if (getParameters().getNamed().containsKey("video-file")) { videoFile = new File(getParameters().getNamed().get("video-file")); if (!videoFile.isFile()) { throw new IllegalArgumentException("The provided video file does not exist"); } } else { final FileChooser chooser = new FileChooser(); chooser.setTitle("Open a video file"); videoFile = chooser.showOpenDialog(stage); } // Exit if no directory selected if (videoFile == null) { stop(); } VBox box = new VBox(); MenuBar bar = createMenuBar(); bar.setUseSystemMenuBar(true); box.getChildren().add(bar); // Ask the user for a connection DatabaseConnectionDialog dialog = new DatabaseConnectionDialog("mysql"); dialog.showAndWait(); if (!dialog.succeeded()) { stop(); } trajectoryDataStore = new DatabaseTrajectoryDataStore(dialog.getDataSource(), dialog.getPointsTableName(), dialog.getTrajectoriesTableName()); FrameSource finder = new FrameCache(new FFMpegFrameFinder(videoFile)); model = new DataStoringPlaybackControlModel(finder, trajectoryDataStore); Tracker tracker = new Tracker(finder, new TemplateTracker.Config(20, 20)); FrameCanvas canvas = new FrameCanvas(tracker); canvas.imageProperty().bind(model.currentFrameImageProperty()); canvas.setDataStore(trajectoryDataStore); model.bindMarkers(canvas); box.getChildren().add(new CanvasPane<>(canvas)); final PlaybackControlPane controls = new PlaybackControlPane(model); box.getChildren().add(controls); // Create image options window final ImageAdjustWindow imageAdjust = new ImageAdjustWindow(); imageAdjust.initOwner(stage); canvas.brightnessProperty().bindBidirectional(imageAdjust.getView().brightnessProperty()); canvas.contrastProperty().bindBidirectional(imageAdjust.getView().contrastProperty()); canvas.hueProperty().bindBidirectional(imageAdjust.getView().hueProperty()); canvas.saturationProperty().bindBidirectional(imageAdjust.getView().saturationProperty()); controls.setOnImageControlsRequested((ActionEvent event) -> { imageAdjust.show(); }); // Hook up the trajectory display options canvas.displayModeProperty().bindBidirectional(controls.trajectoryDisplayModeProperty()); canvas.trajectoryAlphaProperty().bindBidirectional(controls.trajectoryAlphaProperty()); canvas.activeTrajectoryAlphaProperty().bindBidirectional(controls.activeTrajectoryAlphaProperty()); // Hook up trajectory tool select canvas.trajectoryToolProperty().bindBidirectional(controls.trajectoryToolProperty()); // Hook up refresh action controls.setOnRefreshRequested((ActionEvent t) -> { try { trajectoryDataStore.refresh(); } catch (IOException ex) { showDialog(ex); } }); //Assemble the root StackPane StackPane root = new StackPane(); root.getChildren().add(box); stage.setTitle("Frame Viewer"); Scene scene = new Scene(root); controls.setupAccelerators(); stage.setScene(scene); stage.show(); } catch (Throwable ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, "Initialization failed", ex); showDialog(ex); stop(); } }
From source file:User.java
private HBox drawRow2() { PasswordField passwordField = new PasswordField(); passwordField.setFont(Font.font("SanSerif", 20)); passwordField.setPromptText("Password"); passwordField.setStyle(/*from www.j a v a2s . c om*/ "-fx-text-fill:black; " + "-fx-prompt-text-fill:gray; " + "-fx-highlight-text-fill:black; " + "-fx-highlight-fill: gray; " + "-fx-background-color: rgba(255, 255, 255, .80); "); passwordField.prefWidthProperty().bind(primaryStage.widthProperty().subtract(55)); user.passwordProperty().bind(passwordField.textProperty()); // error icon SVGPath deniedIcon = new SVGPath(); deniedIcon.setFill(Color.rgb(255, 0, 0, .9)); deniedIcon.setStroke(Color.WHITE);// deniedIcon.setContent("M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 " + "16.447,13.08710.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10" + ".946,24.248 16.447,18.746 21.948,24.248z"); deniedIcon.setVisible(false); SVGPath grantedIcon = new SVGPath(); grantedIcon.setFill(Color.rgb(0, 255, 0, .9)); grantedIcon.setStroke(Color.WHITE);// grantedIcon.setContent( "M2.379,14.729 5.208,11.899 12.958,19.648 25.877," + "6.733 28.707,9.56112.958,25.308z"); grantedIcon.setVisible(false); // StackPane accessIndicator = new StackPane(); accessIndicator.getChildren().addAll(deniedIcon, grantedIcon); accessIndicator.setAlignment(Pos.CENTER_RIGHT); grantedIcon.visibleProperty().bind(GRANTED_ACCESS); // user hits the enter key passwordField.setOnAction(actionEvent -> { if (GRANTED_ACCESS.get()) { System.out.printf("User %s is granted access.\n", user.getUserName()); System.out.printf("User %s entered the password: %s\n", user.getUserName(), user.getPassword()); Platform.exit(); } else { deniedIcon.setVisible(true); } ATTEMPTS.set(ATTEMPTS.add(1).get()); System.out.println("Attempts: " + ATTEMPTS.get()); }); // listener when the user types into the password field passwordField.textProperty().addListener((obs, ov, nv) -> { boolean granted = passwordField.getText().equals(MY_PASS); GRANTED_ACCESS.set(granted); if (granted) { deniedIcon.setVisible(false); } }); // listener on number of attempts ATTEMPTS.addListener((obs, ov, nv) -> { if (MAX_ATTEMPTS == nv.intValue()) { // failed attempts System.out.printf("User %s is denied access.\n", user.getUserName()); Platform.exit(); } }); // second row HBox row2 = new HBox(3); row2.getChildren().addAll(passwordField, accessIndicator); return row2; }
From source file:org.pdfsam.App.java
@Override public void start(Stage primaryStage) { STOPWATCH.start();/*from ww w . j ava2s. co m*/ LOG.info(DefaultI18nContext.getInstance().i18n("Starting pdfsam")); List<String> styles = (List<String>) ApplicationContextHolder.getContext().getBean("styles"); Map<String, Image> logos = ApplicationContextHolder.getContext().getBeansOfType(Image.class); MainPane mainPane = ApplicationContextHolder.getContext().getBean(MainPane.class); NotificationsContainer notifications = ApplicationContextHolder.getContext() .getBean(NotificationsContainer.class); StackPane main = new StackPane(); StackPane.setAlignment(notifications, Pos.BOTTOM_RIGHT); StackPane.setAlignment(mainPane, Pos.TOP_LEFT); main.getChildren().addAll(mainPane, notifications); Scene scene = new Scene(main); scene.getStylesheets().addAll(styles); primaryStage.setScene(scene); primaryStage.getIcons().addAll(logos.values()); primaryStage.setTitle(ApplicationContextHolder.getContext().getBean("appName", String.class)); scene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN), () -> eventStudio().broadcast(new ShowStageRequest(), "LogStage")); primaryStage.show(); eventStudio().add(new TitleController(primaryStage)); requestCheckForUpdateIfNecessary(); eventStudio().addAnnotatedListeners(this); STOPWATCH.stop(); LOG.info(DefaultI18nContext.getInstance().i18n("Started in {0}", DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true))); }