Example usage for javafx.scene.layout StackPane StackPane

List of usage examples for javafx.scene.layout StackPane StackPane

Introduction

In this page you can find the example usage for javafx.scene.layout StackPane StackPane.

Prototype

public StackPane() 

Source Link

Document

Creates a StackPane layout with default CENTER alignment.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    String workingDir = System.getProperty("user.dir");
    final File f = new File(workingDir, "../media/omgrobots.flv");

    final Media m = new Media(f.toURI().toString());
    final MediaPlayer mp = new MediaPlayer(m);
    final MediaView mv = new MediaView(mp);

    final DoubleProperty width = mv.fitWidthProperty();
    final DoubleProperty height = mv.fitHeightProperty();

    width.bind(Bindings.selectDouble(mv.sceneProperty(), "width"));
    height.bind(Bindings.selectDouble(mv.sceneProperty(), "height"));

    mv.setPreserveRatio(true);/*  w w  w  .  ja v a 2  s .c  om*/

    StackPane root = new StackPane();
    root.getChildren().add(mv);

    final Scene scene = new Scene(root, 960, 540);
    scene.setFill(Color.BLACK);

    primaryStage.setScene(scene);
    primaryStage.setTitle("Full Screen Video Player");
    primaryStage.setFullScreen(true);
    primaryStage.show();

    mp.play();
}

From source file:com.epitech.oliver_f.astextexls.MainClass.java

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Hello World!");
    DirectoryChooser dChooser = new DirectoryChooser();
    dChooser.setTitle("Choose the directory of the excel files");
    File defaultDirectory = new File("c:/");
    dChooser.setInitialDirectory(defaultDirectory);
    File selectedDirectory = dChooser.showDialog(primaryStage);
    StackPane root = new StackPane();
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open excel 'ALL' File");
    File choosenFile = fileChooser.showOpenDialog(primaryStage);
    launchWriteAndRead(selectedDirectory.getAbsolutePath(), choosenFile.getAbsolutePath());
    //root.getChildren().add(btn);
    //primaryStage.setScene(new Scene(root, 300, 250));
    //primaryStage.show();
    Platform.exit();/*from  w ww .  j  a v a2 s  .  c o m*/

}

From source file:org.pdfsam.App.java

@Override
public void start(Stage primaryStage) {
    STOPWATCH.start();//from w w  w.  j  a va2s  .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)));
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group p = new Group();
    Scene scene = new Scene(p);
    stage.setScene(scene);//www .j  a va  2 s . 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:com.cdd.bao.editor.endpoint.BrowseEndpoint.java

public BrowseEndpoint(Stage stage) {
    this.stage = stage;

    stage.setTitle("BioAssay Schema Browser");

    treeRoot = new TreeItem<>(new Branch(this));
    treeView = new TreeView<>(treeRoot);
    treeView.setEditable(true);//from  w  w  w .jav  a2s . c  om
    treeView.setCellFactory(p -> new BrowseTreeCell());
    treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldval, newval) -> {
        changeValue(newval.getValue());
    });

    display = new DisplaySchema();

    StackPane sp1 = new StackPane(), sp2 = new StackPane();
    sp1.getChildren().add(treeView);
    sp2.getChildren().add(display);

    splitter = new SplitPane();
    splitter.setOrientation(Orientation.HORIZONTAL);
    splitter.getItems().addAll(sp1, sp2);
    splitter.setDividerPositions(0.4, 1.0);

    root = new BorderPane();
    root.setTop(menuBar);
    root.setCenter(splitter);

    Scene scene = new Scene(root, 700, 600, Color.WHITE);

    stage.setScene(scene);

    treeView.setShowRoot(false);

    rebuildTree();

    Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item

    new Thread(() -> backgroundLoadTemplates()).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);/*from www  .j  ava 2  s.c  o 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:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java

public ApplicationContext() {
    mainStackPane = new StackPane();
    mainPane = new BorderPane();
    mainPane.setId("background");//important for css
    mainStackPane.getChildren().add(mainPane);
    messageProvider = new MessageProvider(ResourceBundle.getBundle("de.scoopgmbh.copper.gui.message"));

    final Preferences prefs = Preferences.userRoot().node("de.scoopgmbh.coppermonitor");

    SettingsModel defaultSettings = new SettingsModel();
    AuditralColorMapping newItem = new AuditralColorMapping();
    newItem.color.setValue(Color.rgb(255, 128, 128));
    newItem.loglevelRegEx.setValue("1");
    defaultSettings.auditralColorMappings.add(newItem);
    byte[] defaultModelbytes;
    ByteArrayOutputStream os = null;
    try {//from  w  ww .j  a  v  a 2  s.c  o  m
        os = new ByteArrayOutputStream();
        ObjectOutputStream o = new ObjectOutputStream(os);
        o.writeObject(defaultSettings);
        defaultModelbytes = os.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    settingsModelSingleton = defaultSettings;
    ByteArrayInputStream is = null;
    try {
        is = new ByteArrayInputStream(prefs.getByteArray(SETTINGS_KEY, defaultModelbytes));
        ObjectInputStream o = new ObjectInputStream(is);
        Object object = o.readObject();
        if (object instanceof SettingsModel) {
            settingsModelSingleton = (SettingsModel) object;
        }
    } catch (Exception e) {
        logger.error("", e);
        getIssueReporterSingleton()
                .reportWarning("Can't load settings from (Preferences: " + prefs + ") use defaults instead", e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            ByteArrayOutputStream os = null;
            try {
                os = new ByteArrayOutputStream();
                ObjectOutputStream o = new ObjectOutputStream(os);
                o.writeObject(settingsModelSingleton);
                prefs.putByteArray(SETTINGS_KEY, os.toByteArray());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                if (os != null) {
                    try {
                        os.close();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }));
}

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  ww.  j a v  a 2s  .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:org.openbase.display.DisplayView.java

public DisplayView() throws InstantiationException {
    try {//from   www  .ja v  a 2 s . co  m
        this.webTabMap = new HashMap<>();
        this.webTabUsageQueue = new ConcurrentLinkedQueue<>();
        this.htmlLoader = new HTMLLoader();
        this.cardsPane = new StackPane();

        int tmpMaxTabAmount;
        try {
            tmpMaxTabAmount = JPService.getProperty(JPTabAmount.class).getValue();
        } catch (JPServiceException ex) {
            tmpMaxTabAmount = AMOUNT_OF_TAB_FALLBACK;
        }
        this.maxTabAmount = tmpMaxTabAmount;
    } catch (CouldNotPerformException ex) {
        throw new InstantiationException(this, ex);
    }
}

From source file:org.copperengine.monitoring.client.context.ApplicationContext.java

public ApplicationContext(String contextId) {
    this.contextId = contextId;
    mainStackPane = new StackPane();
    mainPane = new BorderPane();
    mainStackPane.getChildren().add(mainPane);
    messageProvider = new MessageProvider(ResourceBundle.getBundle("org.copperengine.gui.message"));

    final Preferences prefs = Preferences.userRoot().node("org.copperengine.coppermonitor");

    SettingsModel defaultSettings = new SettingsModel();
    AuditralColorMapping newItem = new AuditralColorMapping();
    newItem.color.setValue(Color.rgb(255, 128, 128));
    newItem.loglevelRegEx.setValue("1");
    defaultSettings.auditralColorMappings.add(newItem);

    byte[] defaultModelbytes;
    ByteArrayOutputStream os = null;
    try {/*w  w  w.  j  a  v a 2  s.  c  o  m*/
        os = new ByteArrayOutputStream();
        ObjectOutputStream o = new ObjectOutputStream(os);
        o.writeObject(defaultSettings);
        defaultModelbytes = os.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    try {
        settingsModelSingleton = SettingsModel.from(prefs, defaultModelbytes, contextId);
    } catch (Exception e) {
        logger.error("", e);
        getIssueReporterSingleton()
                .reportWarning("Can't load settings from (Preferences: " + prefs + ") use defaults instead", e);
        settingsModelSingleton = defaultSettings;
    }

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            settingsModelSingleton.saveSettings(prefs, ApplicationContext.this.contextId);
        }
    }));
}