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:isbnfilter.ISBNFilter.java

@Override
public void start(Stage primaryStage) {
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override/*from   www . ja va2  s  .c om*/
        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 av a 2 s.  com*/
            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:gov.va.isaac.gui.util.ErrorMarkerUtils.java

/**
 * Setup an 'INFORMATION' info marker on the component. Automatically displays anytime that the initialControl is disabled.
 *///from  www.  j  a va  2 s .c o  m
public static Node setupDisabledInfoMarker(Control initialControl,
        ObservableStringValue reasonWhyControlDisabled) {
    return setupDisabledInfoMarker(initialControl, new StackPane(), reasonWhyControlDisabled);
}

From source file:User.java

private HBox drawRow2() {
    PasswordField passwordField = new PasswordField();
    passwordField.setFont(Font.font("SanSerif", 20));
    passwordField.setPromptText("Password");
    passwordField.setStyle(//from   w w  w  .  j a  v a  2  s  .co  m
            "-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:com.bekwam.mavenpomupdater.Main.java

@Override
public void start(Stage primaryStage) throws Exception {

    //// ww  w. j a  v  a  2 s . c  o  m
    // handle command line options
    //
    Application.Parameters params = getParameters();

    List<String> unnamedList = params.getUnnamed();

    Options options = new Options();
    options.addOption("help", false, "Print this message");
    options.addOption("hidpi", false, "Use high-DPI scaling");

    CommandLineParser p = new BasicParser();
    CommandLine cmd = p.parse(options, unnamedList.toArray(new String[0]));

    HelpFormatter formatter = new HelpFormatter();

    if (cmd.hasOption("help")) {
        if (log.isDebugEnabled()) {
            log.debug("[START] running as help command");
        }
        formatter.printHelp("Main", options);
        return;
    }

    AbstractModule module = null;
    if (runningAsJNLP()) {

        if (log.isInfoEnabled()) {
            log.info("using jnlp module and jnlp favorites store");
        }
        module = new MPUJNLPModule();
    } else {

        if (log.isInfoEnabled()) {
            log.info("using standalone module and in-memory favorites store");
        }
        module = new MPUStandaloneModule();
    }

    //
    // setup google guice
    //
    final Injector injector = Guice.createInjector(module);

    BuilderFactory builderFactory = new JavaFXBuilderFactory();

    Callback<Class<?>, Object> guiceControllerFactory = clazz -> injector.getInstance(clazz);

    //
    // setup icons
    //
    primaryStage.getIcons().add(new Image("images/mpu_icon_64.png"));

    //
    // load fxml and wire controllers
    //
    FXMLLoader mainViewLoader = new FXMLLoader(getClass().getResource("mavenpomupdater.fxml"), null,
            builderFactory, guiceControllerFactory);
    Parent mainView = mainViewLoader.load();
    MainViewController mainViewController = mainViewLoader.getController();

    FXMLLoader alertViewLoader = new FXMLLoader(getClass().getResource("alert.fxml"), null, builderFactory,
            guiceControllerFactory);
    Parent alertView = alertViewLoader.load();

    //
    // i'm continuing this manual wiring to 1) accommodate a potential
    // bi-directional reference problem and 2) to make sure that guice
    // doesn't return different object for the main -> alert and alert ->
    // main dependency injections
    //

    final AlertController alertController = alertViewLoader.getController();
    mainViewController.alertController = alertController;
    alertController.mainViewControllerRef = new WeakReference<MainViewController>(mainViewController);

    //
    // add FlowPane, StackPane objects (defined in program and outside of 
    // FXML)
    //
    final FlowPane fp = new FlowPane();
    fp.setAlignment(Pos.CENTER);
    fp.getChildren().add(alertView);
    fp.getStyleClass().add("alert-background-pane");

    final StackPane sp = new StackPane();
    sp.getChildren().add(fp); // initially hide the alert
    sp.getChildren().add(mainView);

    //
    // setup scene
    //
    Scene scene = new Scene(sp);
    scene.getStylesheets().add("com/bekwam/mavenpomupdater/mpu.css");

    scene.setOnKeyPressed(keyEvent -> {
        KeyCode key = keyEvent.getCode();
        if (key == KeyCode.ESCAPE && (sp.getChildren().get(1) == fp)) {
            if (log.isDebugEnabled()) {
                log.debug("[ESCAPE]");
            }
            alertController.action();
        }
    });

    //
    // setup stage
    //
    primaryStage.setTitle("Maven POM Version Updater");
    primaryStage.setScene(scene);

    if (cmd.hasOption("hidpi")) {

        if (log.isInfoEnabled()) {
            log.info("running in Hi-DPI display mode");
        }
        primaryStage.setWidth(2560.0);
        primaryStage.setHeight(1440.0);
        primaryStage.setMinWidth(1920.0);
        primaryStage.setMinHeight(1080.0);

        mainViewController.adjustForHiDPI();

    } else {
        if (log.isInfoEnabled()) {
            log.info("running in normal display mode");
        }

        primaryStage.setWidth(1280.0);
        primaryStage.setHeight(800.0);
        primaryStage.setMinWidth(1024.0);
        primaryStage.setMinHeight(768.0);

    }

    primaryStage.show();
}

From source file:org.samcrow.frameviewer.App.java

@Override
public void start(final Stage stage) {

    try {//from   w w w.j  a  v a  2  s.  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:org.pdfsam.PdfsamApp.java

private void initScene() {
    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);

    StylesConfig styles = ApplicationContextHolder.getContext().getBean(StylesConfig.class);

    mainScene = new Scene(main);
    mainScene.getStylesheets().addAll(styles.styles());
    mainScene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN),
            () -> eventStudio().broadcast(new ShowStageRequest(), "LogStage"));
}

From source file:com.cdd.bao.editor.EditSchema.java

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

    if (MainApplication.icon != null)
        stage.getIcons().add(MainApplication.icon);

    menuBar = new MenuBar();
    menuBar.setUseSystemMenuBar(true);//from   ww w. j a v  a2  s.c  o m
    menuBar.getMenus().add(menuFile = new Menu("_File"));
    menuBar.getMenus().add(menuEdit = new Menu("_Edit"));
    menuBar.getMenus().add(menuValue = new Menu("_Value"));
    menuBar.getMenus().add(menuView = new Menu("Vie_w"));
    createMenuItems();

    treeRoot = new TreeItem<>(new Branch(this));
    treeView = new TreeView<>(treeRoot);
    treeView.setEditable(true);
    treeView.setCellFactory(p -> new HierarchyTreeCell());
    treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> {
        if (oldVal != null)
            pullDetail(oldVal);
        if (newVal != null)
            pushDetail(newVal);
    });
    treeView.focusedProperty()
            .addListener((val, oldValue, newValue) -> Platform.runLater(() -> maybeUpdateTree()));

    detail = new DetailPane(this);

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

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

    progBar = new ProgressBar();
    progBar.setMaxWidth(Double.MAX_VALUE);

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

    BorderPane.setMargin(progBar, new Insets(2, 2, 2, 2));

    Scene scene = new Scene(root, 1000, 800, Color.WHITE);

    stage.setScene(scene);

    treeView.setShowRoot(false);
    treeRoot.getChildren().add(treeTemplate = new TreeItem<>(new Branch(this, "Template")));
    treeRoot.getChildren().add(treeAssays = new TreeItem<>(new Branch(this, "Assays")));
    treeTemplate.setExpanded(true);
    treeAssays.setExpanded(true);

    rebuildTree();

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

    stage.setOnCloseRequest(event -> {
        if (!confirmClose())
            event.consume();
    });

    updateTitle();

    // loading begins in a background thread, and is updated with a status bar
    Vocabulary.Listener listener = new Vocabulary.Listener() {
        public void vocabLoadingProgress(Vocabulary vocab, float progress) {
            Platform.runLater(() -> {
                progBar.setProgress(progress);
                if (vocab.isLoaded())
                    root.getChildren().remove(progBar);
            });
        }

        public void vocabLoadingException(Exception ex) {
            ex.printStackTrace();
        }
    };
    Vocabulary.globalInstance(listener);
}

From source file:Main.java

private void addStackPane(HBox hb) {

    StackPane stack = new StackPane();
    Rectangle helpIcon = new Rectangle(30.0, 25.0);
    helpIcon.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE,
            new Stop[] { new Stop(0, Color.web("#4977A3")), new Stop(0.5, Color.web("#B0C6DA")),
                    new Stop(1, Color.web("#9CB6CF")), }));
    helpIcon.setStroke(Color.web("#D0E6FA"));
    helpIcon.setArcHeight(3.5);/*from ww w. j a v a  2s . c  o m*/
    helpIcon.setArcWidth(3.5);

    Text helpText = new Text("?");
    helpText.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
    helpText.setFill(Color.WHITE);
    helpText.setStroke(Color.web("#7080A0"));

    stack.getChildren().addAll(helpIcon, helpText);
    stack.setAlignment(Pos.CENTER_RIGHT);
    // Add offset to right for question mark to compensate for RIGHT 
    // alignment of all nodes
    StackPane.setMargin(helpText, new Insets(0, 10, 0, 0));

    hb.getChildren().add(stack);
    HBox.setHgrow(stack, Priority.ALWAYS);

}

From source file:de.hs.mannheim.modUro.controller.diagram.fx.ChartViewerSkin.java

/**
 * Creates the node representing this control.
 *
 * @return The node./*from  ww w  .j  a  va 2 s  .  co  m*/
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(150, 200);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());

    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);

    borderPane.setCenter(sp);
    return borderPane;
}