Example usage for javafx.scene.layout AnchorPane setBottomAnchor

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

Introduction

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

Prototype

public static void setBottomAnchor(Node child, Double value) 

Source Link

Document

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

Usage

From source file:cz.lbenda.dataman.db.sql.SQLEditorController.java

@SuppressWarnings("unchecked")
public SQLEditorController(Consumer<Object> menuItemConsumer, Scene scene,
        ObjectProperty<DbConfig> dbConfigProperty, NodeShower nodeShower) {
    node.setMaxHeight(Double.MAX_VALUE);
    node.setMaxHeight(Double.MAX_VALUE);

    this.nodeShower = nodeShower;

    textEditor.setScene(scene);//from   w ww .  ja  v a  2  s  . c om
    textEditor.changeHighlighter(new HighlighterSQL());

    nodeShower.addNode(webView, msgConsoleTitle, false);

    CodeArea ca = textEditor.createCodeArea();
    ca.setMaxHeight(Double.MAX_VALUE);
    ca.setMaxWidth(Double.MAX_VALUE);
    AnchorPane.setTopAnchor(ca, 0.0);
    AnchorPane.setBottomAnchor(ca, 0.0);
    AnchorPane.setLeftAnchor(ca, 0.0);
    AnchorPane.setRightAnchor(ca, 0.0);
    node.getChildren().add(ca);

    menuItemConsumer
            .accept(new SQLRunHandler(dbConfigProperty, this, handler -> nodeShower.focusNode(webView)));
    menuItemConsumer
            .accept(new SQLRunAllHandler(dbConfigProperty, this, handler -> nodeShower.focusNode(webView)));
    menuItemConsumer.accept(new OpenFileHandler(this));
    menuItemConsumer.accept(new SaveFileHandler(this));
    menuItemConsumer.accept(new SaveAsFileHandler(this));
    menuItemConsumer.accept(new StopOnFirstErrorOptions(stopOnFirstError));
}

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

/**
 *
 * @param content//from  ww  w  .  j  a va2  s . 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. j  a va2 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);/*from  www.  jav  a 2s  . c  o m*/
    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);/*www. j  av a2 s .com*/
    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.
 */// ww  w . j  av  a  2  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 showWinner(Board.WinnerInfo winnerInfo) {
    guiAnimationQueue.submitWaitForUnlock(
            () -> addWinLineOnWin(winnerInfo, new Color(1.0, 145.0 / 255.0, 30.0 / 255.0, 1.0), () -> {
                winnerText.setText(winnerInfo.winningPlayer.getName() + " won :)");
                double endX = winningGirl.getX();
                double endY = winningGirl.getY();

                double confettiOffset = 30;

                double confettiX = confetti.getX();
                double confettiY = confetti.getY();

                AnchorPane.clearConstraints(winningGirl);
                winningGirl.setX(endX);//from  w w w .  j  a va2s.  c  o m
                winningGirl.setY(root.getHeight() + 140);

                blurGamePane();
                winMessage.setOpacity(0);
                confetti.setOpacity(0);
                winPane.setOpacity(1);
                winPane.setVisible(true);
                winningGirl.setVisible(true);

                Timeline timeline = new Timeline();
                double S4 = 1.45;
                double x0 = 0.33;
                KeyValue confettiKeyValue1x = new KeyValue(confetti.xProperty(), confettiX);
                KeyValue confettiKeyValue1y = new KeyValue(confetti.yProperty(), confettiY - confettiOffset);
                KeyValue confettiKeyValue1opacity = new KeyValue(confetti.opacityProperty(), 0);
                KeyFrame confettiKeyFrame1 = new KeyFrame(Duration.seconds(0), confettiKeyValue1x,
                        confettiKeyValue1y, confettiKeyValue1opacity);

                KeyValue confettiKeyValue2x = new KeyValue(confetti.xProperty(), confettiX);
                KeyValue confettiKeyValue2y = new KeyValue(confetti.yProperty(), confettiY - confettiOffset);
                KeyValue confettiKeyValue2opacity = new KeyValue(confetti.opacityProperty(), 0);
                KeyFrame confettiKeyFrame2 = new KeyFrame(Duration.millis(500), confettiKeyValue2x,
                        confettiKeyValue2y, confettiKeyValue2opacity);

                KeyValue confettiKeyValue3x = new KeyValue(confetti.xProperty(), confettiX,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyValue confettiKeyValue3y = new KeyValue(confetti.yProperty(), confettiY,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyValue confettiKeyValue3opacity = new KeyValue(confetti.opacityProperty(), 1);
                KeyFrame confettiKeyFrame3 = new KeyFrame(Duration.millis(1100), confettiKeyValue3x,
                        confettiKeyValue3y, confettiKeyValue3opacity);

                KeyValue winningGirlKeyValue1x = new KeyValue(winningGirl.xProperty(), endX,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyValue winningGirlKeyValue1y = new KeyValue(winningGirl.yProperty(), endY,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyFrame winningGirlKeyFrame1 = new KeyFrame(Duration.seconds(1), winningGirlKeyValue1x,
                        winningGirlKeyValue1y);
                timeline.getKeyFrames().addAll(winningGirlKeyFrame1, confettiKeyFrame1, confettiKeyFrame2,
                        confettiKeyFrame3);

                timeline.setOnFinished((event) -> fadeNode(winMessage, 1, () -> {
                    AnchorPane.setRightAnchor(winningGirl, 0.0);
                    AnchorPane.setBottomAnchor(winningGirl, 0.0);
                }));

                timeline.play();
            }));
}

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

private void showWinnerWithTwoHumanPlayers(Board.WinnerInfo winnerInfo) {
    guiAnimationQueue.submitWaitForUnlock(() -> addWinLineOnWin(winnerInfo, Color.YELLOW, () -> {
        twoHumansWinnerText.setText(winnerInfo.winningPlayer.getName() + " won :)");
        double endX = twoHumansWinnerImage.getX();
        double endY = twoHumansWinnerImage.getY();

        AnchorPane.clearConstraints(twoHumansWinnerImage);
        twoHumansWinnerImage.setX(endX);
        twoHumansWinnerImage.setY(twoHumansWinnerImage.getY() + 300);

        // blurGamePane();
        blurGamePane(10.0);//from   w w w  .  j ava2 s  . c om
        twoHumansWinMessage.setOpacity(0);
        twoHumansWinnerImage.setOpacity(0);
        twoHumansWinnerPane.setOpacity(1);
        twoHumansWinnerPane.setVisible(true);
        twoHumansWinnerImage.setVisible(true);

        Timeline timeline = new Timeline();
        double S4 = 1.45;
        double x0 = 0.33;

        KeyValue twoHumansWinnerImageKeyValue1x = new KeyValue(twoHumansWinnerImage.xProperty(), endX,
                new CustomEaseOutInterpolator(S4, x0));
        KeyValue twoHumansWinnerImageKeyValue1y = new KeyValue(twoHumansWinnerImage.yProperty(), endY,
                new CustomEaseOutInterpolator(S4, x0));
        KeyValue twoHumansWinnerImageKeyValue1Opacity = new KeyValue(twoHumansWinnerImage.opacityProperty(), 1);
        KeyFrame twoHumansWinnerImageKeyFrame1 = new KeyFrame(Duration.millis(600),
                twoHumansWinnerImageKeyValue1x, twoHumansWinnerImageKeyValue1y,
                twoHumansWinnerImageKeyValue1Opacity);
        timeline.getKeyFrames().addAll(twoHumansWinnerImageKeyFrame1);

        timeline.setOnFinished((event) -> fadeNode(twoHumansWinMessage, 1, () -> {
            AnchorPane.setLeftAnchor(twoHumansWinnerImage, 0.0);
            AnchorPane.setBottomAnchor(twoHumansWinnerImage, 0.0);
        }));

        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 www.  ja v a 2  s  . co m*/
 * @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);//  w  ww .j a v  a  2  s  .  com
    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);
}