Example usage for javafx.scene.layout AnchorPane setTopAnchor

List of usage examples for javafx.scene.layout AnchorPane setTopAnchor

Introduction

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

Prototype

public static void setTopAnchor(Node child, Double value) 

Source Link

Document

Sets the top anchor for the child when contained by an anchor pane.

Usage

From source file:context.ui.control.workflow.WorkflowController.java

/**
 *
 * @param content/*from   ww  w . j  av a2s . c  o m*/
 */
protected void boundToPane(Parent content) {
    AnchorPane.setTopAnchor(content, 0.0);
    AnchorPane.setLeftAnchor(content, 0.0);
    AnchorPane.setBottomAnchor(content, 0.0);
    AnchorPane.setRightAnchor(content, 0.0);
}

From source file:com.neuronrobotics.bowlerstudio.MainController.java

/**
 * Initializes the controller class./*  w  w w.jav  a2  s . c o  m*/
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    ScriptingEngine.setLoginManager(new IGitHubLoginManager() {

        @Override
        public String[] prompt(String username) {
            if (!loginWindowOpen && controller != null)
                controller.reset();
            loginWindowOpen = true;
            System.err.println("Calling login from BowlerStudio");
            // new RuntimeException().printStackTrace();
            FXMLLoader fxmlLoader = BowlerStudioResourceFactory.getGithubLogin();
            Parent root = fxmlLoader.getRoot();
            if (controller == null) {
                controller = fxmlLoader.getController();
                Platform.runLater(() -> {
                    controller.reset();
                    controller.getUsername().setText(username);
                    Stage stage = new Stage();
                    stage.setTitle("GitHub Login");
                    stage.initModality(Modality.APPLICATION_MODAL);
                    controller.setStage(stage, root);
                    stage.centerOnScreen();
                    stage.show();
                });
            }
            // setContent(root);
            while (!controller.isDone()) {
                ThreadUtil.wait(100);
            }
            String[] creds = controller.getCreds();
            loginWindowOpen = false;
            return creds;
        }
    });

    jfx3dmanager = new BowlerStudio3dEngine();

    setApplication(new BowlerStudioController(jfx3dmanager, this));
    Platform.runLater(() -> {
        editorContainer.getChildren().add(getApplication());
        AnchorPane.setTopAnchor(getApplication(), 0.0);
        AnchorPane.setRightAnchor(getApplication(), 0.0);
        AnchorPane.setLeftAnchor(getApplication(), 0.0);
        AnchorPane.setBottomAnchor(getApplication(), 0.0);

        subScene = jfx3dmanager.getSubScene();
        subScene.setFocusTraversable(false);
        subScene.setOnMouseEntered(mouseEvent -> {
            // System.err.println("3d window requesting focus");
            Scene topScene = BowlerStudio.getScene();
            normalKeyPessHandle = topScene.getOnKeyPressed();
            jfx3dmanager.handleKeyboard(topScene);
        });

        subScene.setOnMouseExited(mouseEvent -> {
            // System.err.println("3d window dropping focus");
            Scene topScene = BowlerStudio.getScene();
            topScene.setOnKeyPressed(normalKeyPessHandle);
        });

        subScene.widthProperty().bind(viewContainer.widthProperty());
        subScene.heightProperty().bind(viewContainer.heightProperty());
    });

    Platform.runLater(() -> {
        jfx3dControls.getChildren().add(jfx3dmanager.getControlsBox());
        viewContainer.getChildren().add(subScene);
    });

    System.out.println("Welcome to BowlerStudio!");
    new Thread() {
        public void run() {
            setName("Load Haar Thread");
            try {
                HaarFactory.getStream(null);
            } catch (Exception ex) {
            }
        }
    }.start();

    // getAddDefaultRightArm().setOnAction(event -> {
    //
    // application.onAddDefaultRightArm(event);
    // });
    // getAddVRCamera().setOnAction(event -> {
    // if(AddVRCamera.isSelected())
    // application.onAddVRCamera(event);
    // });

    FxTimer.runLater(Duration.ofMillis(100), () -> {
        if (ScriptingEngine.getLoginID() != null) {
            setToLoggedIn(ScriptingEngine.getLoginID());
        } else {
            setToLoggedOut();
        }

    });

    ScriptingEngine.addIGithubLoginListener(new IGithubLoginListener() {

        @Override
        public void onLogout(String oldUsername) {
            setToLoggedOut();
        }

        @Override
        public void onLogin(String newUsername) {
            setToLoggedIn(newUsername);

        }
    });

    cmdLine = new CommandLineWidget();

    Platform.runLater(() -> {
        // logView.resize(250, 300);
        // after connection manager set up, add scripting widget
        logViewRef = new TextArea();
        logViewRef.prefWidthProperty().bind(logView.widthProperty().divide(2));
        logViewRef.prefHeightProperty().bind(logView.heightProperty().subtract(40));
        VBox box = new VBox();
        box.getChildren().add(logViewRef);
        box.getChildren().add(cmdLine);
        VBox.setVgrow(logViewRef, Priority.ALWAYS);
        box.prefWidthProperty().bind(logView.widthProperty().subtract(10));

        logView.getChildren().addAll(box);
    });
}

From source file:acmi.l2.clientmod.xdat.Controller.java

private static AnchorPane wrap(Node node) {
    AnchorPane anchorPane = new AnchorPane(node);
    AnchorPane.setTopAnchor(node, 0.0);
    AnchorPane.setLeftAnchor(node, 0.0);
    AnchorPane.setRightAnchor(node, 0.0);
    AnchorPane.setBottomAnchor(node, 0.0);
    return anchorPane;
}

From source file:Main.java

private AnchorPane addAnchorPane(GridPane grid) {

    AnchorPane anchorpane = new AnchorPane();

    Button buttonSave = new Button("Save");
    Button buttonCancel = new Button("Cancel");

    HBox hb = new HBox();
    hb.setPadding(new Insets(0, 10, 10, 10));
    hb.setSpacing(10);/*from  ww w.ja  v a2 s  . c  o m*/
    hb.getChildren().addAll(buttonSave, buttonCancel);

    anchorpane.getChildren().addAll(grid, hb);
    // Anchor buttons to bottom right, anchor grid to top
    AnchorPane.setBottomAnchor(hb, 8.0);
    AnchorPane.setRightAnchor(hb, 5.0);
    AnchorPane.setTopAnchor(grid, 10.0);

    return anchorpane;
}

From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownFxPreviewEditor.java

/**
 * Build a new instance of {@link MultiMarkdownFxPreviewEditor}.
 *
 * @param project the {@link Project} containing the document
 * @param doc     the {@link Document} previewed in this editor.
 *///from w w  w. j a  va2  s .c  o m
public MultiMarkdownFxPreviewEditor(@NotNull final Project project, @NotNull Document doc, boolean isRawHtml) {
    this.isRawHtml = isRawHtml;
    this.document = doc;
    this.project = project;
    this.isWikiDocument = isWikiDocument(document);
    containingFile = FileDocumentManager.getInstance().getFile(document);
    resolver = containingFile == null ? null : new GitHubLinkResolver(containingFile, project);

    // Listen to the document modifications.
    this.document.addDocumentListener(new DocumentAdapter() {
        @Override
        public void documentChanged(DocumentEvent e) {
            delayedHtmlPreviewUpdate(false);
        }
    });

    // Listen to settings changes
    MultiMarkdownGlobalSettings.getInstance()
            .addListener(globalSettingsListener = new MultiMarkdownGlobalSettingsListener() {
                public void handleSettingsChanged(@NotNull final MultiMarkdownGlobalSettings newSettings) {
                    if (project.isDisposed())
                        return;
                    processor = null;
                    updateEditorTabIsVisible();
                    updateLinkRenderer();
                    delayedHtmlPreviewUpdate(true);
                    checkNotifyUser();
                }
            });

    MultiMarkdownProjectComponent projectComponent = MultiMarkdownPlugin.getProjectComponent(project);
    if (projectComponent != null) {
        projectComponent.addListener(projectFileListener = new ReferenceChangeListener() {
            @Override
            public void referenceChanged(@Nullable String name) {
                if (project.isDisposed())
                    return;
                delayedHtmlPreviewUpdate(false);
            }
        });
    }

    project.getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
        @Override
        public void enteredDumbMode() {
        }

        @Override
        public void exitDumbMode() {
            // need to re-evaluate class link accessibility
            if (project.isDisposed())
                return;
            delayedHtmlPreviewUpdate(false);
        }
    });

    updateLinkRenderer();

    if (isRawHtml) {
        jEditorPane = null;
        jfxPanel = null;
        webView = null;
        webEngine = null;
        Language language = Language.findLanguageByID("HTML");
        FileType fileType = language != null ? language.getAssociatedFileType() : null;
        Document myDocument = EditorFactory.getInstance().createDocument("");
        myTextViewer = (EditorImpl) EditorFactory.getInstance().createViewer(myDocument, project);
        if (fileType != null)
            myTextViewer.setHighlighter(
                    EditorHighlighterFactory.getInstance().createEditorHighlighter(project, fileType));
    } else {
        // Setup the editor pane for rendering HTML.
        myTextViewer = null;
        jEditorPane = new JPanel(new BorderLayout(), false);
        jfxPanel = new JFXPanel(); // initializing javafx
        jEditorPane.add(jfxPanel, BorderLayout.CENTER);
        Platform.setImplicitExit(false);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                if (project.isDisposed())
                    return;

                webView = new WebView();
                webEngine = webView.getEngine();

                anchorPane = new AnchorPane();
                AnchorPane.setTopAnchor(webView, 0.0);
                AnchorPane.setLeftAnchor(webView, 0.0);
                AnchorPane.setBottomAnchor(webView, 0.0);
                AnchorPane.setRightAnchor(webView, 0.0);
                anchorPane.getChildren().add(webView);
                jfxPanel.setScene(new Scene(anchorPane));

                webEngine.setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
                    @Override
                    public WebEngine call(PopupFeatures config) {
                        // return a web engine for the new browser window or null to block popups
                        return null;
                    }
                });

                addStateChangeListener();
            }
        });
    }

    checkNotifyUser();
}

From source file:com.github.vatbub.tictactoe.view.Main.java

private void showTie() {
    guiAnimationQueue.submitWaitForUnlock(() -> {
        double endX = tiePane.getWidth() - 230;
        double endY = 90;

        AnchorPane.clearConstraints(bowTie);
        bowTie.setX(endX);/*from ww w .  j a  v  a2s. c o m*/
        bowTie.setY(-150);

        blurGamePane();
        tieMessage.setOpacity(0);
        tiePane.setOpacity(1);
        tiePane.setVisible(true);
        bowTie.setVisible(true);

        Timeline timeline = new Timeline();
        double S4 = 1.45;
        double x0 = 0.33;
        KeyValue keyValue1x = new KeyValue(bowTie.xProperty(), endX, new CustomEaseOutInterpolator(S4, x0));
        KeyValue keyValue1y = new KeyValue(bowTie.yProperty(), endY, new CustomEaseOutInterpolator(S4, x0));
        KeyFrame keyFrame1 = new KeyFrame(Duration.seconds(1), keyValue1x, keyValue1y);
        timeline.getKeyFrames().add(keyFrame1);

        timeline.setOnFinished((event) -> fadeNode(tieMessage, 1, () -> {
            AnchorPane.setRightAnchor(bowTie, tiePane.getWidth() - bowTie.getFitWidth() - endX);
            AnchorPane.setTopAnchor(bowTie, endY);
        }));

        timeline.play();
    });
}

From source file:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java

/**
 * Handles an exception that caused program startup to fail, by showing an error message to the user.
 * //from   w  w  w .j  av  a 2  s  .  c  om
 * @param title
 *            title for the dialog
 * @param errorMessage
 *            error message
 * @param stage
 *            stage in which to show the error message
 * @param exception
 *            exception that caused the error
 */
public static void show(String title, String errorMessage, final Stage stage, Exception exception) {
    log.info("Showing error message dialog to indicate that startup failed.");

    // Create the error dialog programatically without relying on FXML, to minimize the chances of further failure.

    stage.setTitle(title);

    // Error message text.
    Text text = new Text(errorMessage);

    // Text area containing the stack trace. Not visible by default.
    String stackTrace;
    if (exception != null) {
        stackTrace = ExceptionUtils.getStackTrace(exception);
    } else {
        stackTrace = "No more details available.";
    }
    final TextArea stackTraceArea = new TextArea(stackTrace);
    stackTraceArea.setEditable(false);
    stackTraceArea.setVisible(false);

    // Details button for displaying the stack trace.
    Button detailsButton = new Button();
    detailsButton.setText("Details");
    detailsButton.setOnAction(new EventHandler<ActionEvent>() {
        /** {@inheritDoc} */
        @Override
        public void handle(ActionEvent event) {
            log.info("User clicked Details.");
            stackTraceArea.setVisible(!stackTraceArea.isVisible());
        }
    });

    // OK button for closing the dialog.
    Button okButton = new Button();
    okButton.setText("OK");
    okButton.setOnAction(new EventHandler<ActionEvent>() {
        /** {@inheritDoc} */
        @Override
        public void handle(ActionEvent event) {
            log.info("User clicked OK, closing the dialog.");
            stage.close();
        }
    });

    // Horizontal box containing the buttons, to make sure they are always centered.
    HBox buttonsBox = new HBox(5);
    buttonsBox.getChildren().add(detailsButton);
    buttonsBox.getChildren().add(okButton);
    buttonsBox.setAlignment(Pos.CENTER);

    // Layout constraints.
    AnchorPane.setTopAnchor(text, Double.valueOf(5));
    AnchorPane.setLeftAnchor(text, Double.valueOf(5));
    AnchorPane.setRightAnchor(text, Double.valueOf(5));

    AnchorPane.setTopAnchor(stackTraceArea, Double.valueOf(31));
    AnchorPane.setLeftAnchor(stackTraceArea, Double.valueOf(5));
    AnchorPane.setRightAnchor(stackTraceArea, Double.valueOf(5));
    AnchorPane.setBottomAnchor(stackTraceArea, Double.valueOf(36));

    AnchorPane.setLeftAnchor(buttonsBox, Double.valueOf(5));
    AnchorPane.setRightAnchor(buttonsBox, Double.valueOf(5));
    AnchorPane.setBottomAnchor(buttonsBox, Double.valueOf(5));

    AnchorPane root = new AnchorPane();
    root.getChildren().addAll(text, stackTraceArea, buttonsBox);

    stage.setScene(new Scene(root));

    // Use a standard program icon if possible.
    try {
        stage.getIcons().add(Icons.get().getRandomPortrait());
    } catch (IllegalStateException e) {
        log.warn("Failed to load icon for error dialog; proceeding with default JavaFX icon.", e);
    }

    stage.show();

    // Default size should also be the minimum size.
    stage.setMinWidth(stage.getWidth());
    stage.setMinHeight(stage.getHeight());

    log.info("Error dialog displayed.");
}

From source file:org.apache.cayenne.modeler.layout.LayoutSupport.java

default void displayView(final AnchorPane anchorPane, final Node view) {
    // Remove anything already there.
    anchorPane.getChildren().removeAll(anchorPane.getChildren());

    // Make the view fill the anchor pane.
    AnchorPane.setTopAnchor(view, 0.0);
    AnchorPane.setLeftAnchor(view, 0.0);
    AnchorPane.setRightAnchor(view, 0.0);
    AnchorPane.setBottomAnchor(view, 0.0);

    // Add the view into the anchor pane.
    anchorPane.getChildren().add(view);/*  w w  w. jav a 2  s.  co  m*/
}

From source file:org.jevis.jeconfig.JEConfig.java

/**
 * Build an new JEConfig Login and main frame/stage
 *
 * @param primaryStage//from  w  w w . j  a va 2  s  .  c o  m
 */
//AITBilal - Login  
private void initGUI(Stage primaryStage) {
    Scene scene;
    LoginGlass login = new LoginGlass(primaryStage);

    AnchorPane jeconfigRoot = new AnchorPane();
    AnchorPane.setTopAnchor(jeconfigRoot, 0.0);
    AnchorPane.setRightAnchor(jeconfigRoot, 0.0);
    AnchorPane.setLeftAnchor(jeconfigRoot, 0.0);
    AnchorPane.setBottomAnchor(jeconfigRoot, 0.0);
    //        jeconfigRoot.setStyle("-fx-background-color: white;");
    //        jeconfigRoot.getChildren().setAll(new Label("sodfhsdhdsofhdshdsfdshfjf"));

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    // @AITBilal - Main frame elemente wird aufgerufen nachdem man sich eingeloggt hat.
    login.getLoginStatus().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                System.out.println("after request");
                _mainDS = login.getDataSource();
                ds = _mainDS;

                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        FadeTransition ft = new FadeTransition(Duration.millis(1500), login);
                        ft.setFromValue(1.0);
                        ft.setToValue(0);
                        ft.setCycleCount(1);
                        ft.play();
                    }
                });

                JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo());
                JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO);
                JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO);

                preLodedClasses = login.getAllClasses();
                preLodedRootObjects = login.getRootObjects();

                PluginManager pMan = new PluginManager(ds);
                //@AITBilal - Toolbar fr save, newB, delete, sep1, form
                GlobalToolBar toolbar = new GlobalToolBar(pMan);
                pMan.addPluginsByUserSetting(null);

                //                    StackPane root = new StackPane();
                //                    root.setId("mainpane");
                BorderPane border = new BorderPane();
                VBox vbox = new VBox();
                vbox.getChildren().addAll(new TopMenu(), toolbar.ToolBarFactory());
                border.setTop(vbox);
                //@AITBilal - Alle Plugins Inhalt fr JEConfig (Resources... | System | Attribute)
                border.setCenter(pMan.getView());

                Statusbar statusBar = new Statusbar(ds);

                border.setBottom(statusBar);

                System.out.println("show welcome");

                //Disable GUI is StatusBar note an disconnect
                border.disableProperty().bind(statusBar.connectedProperty.not());

                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        AnchorPane.setTopAnchor(border, 0.0);
                        AnchorPane.setRightAnchor(border, 0.0);
                        AnchorPane.setLeftAnchor(border, 0.0);
                        AnchorPane.setBottomAnchor(border, 0.0);

                        jeconfigRoot.getChildren().setAll(border);
                        //                            try {
                        //            WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://coffee-project.eu/"));
                        //            WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://openjevis.org/projects/openjevis/wiki/JEConfig3#JEConfig-Version-3"));

                        //                            Task<Void> showWelcome = new Task<Void>() {
                        //                                @Override
                        //                                protected Void call() throws Exception {
                        try {
                            WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL());
                        } catch (URISyntaxException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (MalformedURLException ex) {
                            Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        //                                    return null;
                        //                                }
                        //                            };
                        //                            new Thread(showWelcome).start();

                        //                                WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL());
                        //                            } catch (URISyntaxException ex) {
                        //                                Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        //                            } catch (MalformedURLException ex) {
                        //                                Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
                        //                            }
                    }
                });
            }

        }
    });

    AnchorPane.setTopAnchor(login, 0.0);
    AnchorPane.setRightAnchor(login, 0.0);
    AnchorPane.setLeftAnchor(login, 0.0);
    AnchorPane.setBottomAnchor(login, 0.0);
    //@AITBilal - Login Dialog
    scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight());
    scene.getStylesheets().add("/styles/Styles.css");
    primaryStage.getIcons().add(getImage("1393354629_Config-Tools.png"));
    primaryStage.setTitle("JEConfig");
    primaryStage.setScene(scene);
    maximize(primaryStage);
    primaryStage.show();

    //        Platform.runLater(new Runnable() {
    //            @Override
    //            public void run() {
    //@AITBilal - Inhalt bzw. die Elemente von LoginDialog
    jeconfigRoot.getChildren().setAll(login);
    //            }
    //        });

    primaryStage.onCloseRequestProperty().addListener(new ChangeListener<EventHandler<WindowEvent>>() {

        @Override
        public void changed(ObservableValue<? extends EventHandler<WindowEvent>> ov,
                EventHandler<WindowEvent> t, EventHandler<WindowEvent> t1) {
            try {
                System.out.println("Disconnect");
                ds.disconnect();
            } catch (JEVisException ex) {
                Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:org.noroomattheinn.visibletesla.LocationController.java

@Override
protected void fxInitialize() {
    engine = webView.getEngine();//  w w  w .  j a  v a 2  s.  com
    progressIndicator.setVisible(false);
    multigauge = new MultiGauge(25, 8, 0, 100, -60, 320);
    multigauge.useGradient(Side.RIGHT, Color.DARKORANGE, Color.GREEN);
    multigauge.useGradient(Side.LEFT, Color.BLUE, Color.BLUE);
    multigauge.setLogScale(Side.RIGHT, true);
    Node mg = multigauge.getContainer();
    AnchorPane.setTopAnchor(mg, 25.0);
    AnchorPane.setRightAnchor(mg, 10.0);
    root.getChildren().add(2, mg);
    multigauge.setVal(Side.LEFT, 20);
    multigauge.setVal(Side.RIGHT, 40);
}