Example usage for javafx.geometry VPos TOP

List of usage examples for javafx.geometry VPos TOP

Introduction

In this page you can find the example usage for javafx.geometry VPos TOP.

Prototype

VPos TOP

To view the source code for javafx.geometry VPos TOP.

Click Source Link

Document

Indicates top vertical position.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Text msg = new Text("java2s.com");
    msg.setTextOrigin(VPos.TOP);
    msg.setFont(Font.font(24));/*  w w w. j  a v  a2 s  . c o  m*/

    Pane root = new Pane(msg);
    root.setPrefSize(500, 70);
    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.setTitle("Scrolling Text");
    stage.show();

    double sceneWidth = scene.getWidth();
    double msgWidth = msg.getLayoutBounds().getWidth();

    KeyValue initKeyValue = new KeyValue(msg.translateXProperty(), sceneWidth);
    KeyFrame initFrame = new KeyFrame(Duration.ZERO, initKeyValue);

    KeyValue endKeyValue = new KeyValue(msg.translateXProperty(), -1.0 * msgWidth);
    KeyFrame endFrame = new KeyFrame(Duration.seconds(3), endKeyValue);

    Timeline timeline = new Timeline(initFrame, endFrame);

    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);//from   w w  w.jav a  2 s.c o  m

    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0);

    Text t = new Text();
    t.setText("JavaFX!");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 90));
    t.setX(10.0);
    t.setY(10.0);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    box.getChildren().add(t);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group g = new Group();
    final Scene scene = new Scene(g, 300, 250);
    scene.setFill(null);//  w  w  w.j a v a  2  s.c o m

    Light.Spot light = new Light.Spot();
    light.setX(0);
    light.setY(100);
    light.setZ(50);
    light.setPointsAtX(400);
    light.setPointsAtY(0);
    light.setPointsAtZ(0);
    light.setSpecularExponent(2);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0);

    Text t = new Text();
    t.setText("Spot");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 90));
    t.setX(10.0);
    t.setY(10.0);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    Rectangle r = new Rectangle();
    r.setFill(Color.BLACK);

    g.getChildren().add(r);
    g.getChildren().add(t);

    r.setWidth(t.getLayoutBounds().getWidth() + 30);
    r.setHeight(t.getLayoutBounds().getHeight() + 20);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    final Stage stageRef = stage;
    Group rootGroup;//from ww  w .j  ava2 s.c  om
    Scene scene = SceneBuilder.create().width(270).height(370)
            .root(rootGroup = GroupBuilder.create()
                    .children(VBoxBuilder.create().layoutX(30).layoutY(20).spacing(10)
                            .children(textStageX = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageY = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageW = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageH = TextBuilder.create().textOrigin(VPos.TOP).build(),
                                    textStageF = TextBuilder.create().textOrigin(VPos.TOP).build())
                            .build())
                    .build())
            .build();

    textStageX.textProperty().bind(new SimpleStringProperty("x: ").concat(stageRef.xProperty().asString()));
    textStageY.textProperty().bind(new SimpleStringProperty("y: ").concat(stageRef.yProperty().asString()));
    textStageW.textProperty()
            .bind(new SimpleStringProperty("width: ").concat(stageRef.widthProperty().asString()));
    textStageH.textProperty()
            .bind(new SimpleStringProperty("height: ").concat(stageRef.heightProperty().asString()));
    textStageF.textProperty()
            .bind(new SimpleStringProperty("focused: ").concat(stageRef.focusedProperty().asString()));
    stage.setResizable(true);

    stage.setScene(scene);
    stage.titleProperty().bind(title);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    TextField fName = new TextField();
    TextField lName = new TextField();
    TextField salary = new TextField();

    Button closeBtn = new Button("Close");
    closeBtn.setOnAction(e -> Platform.exit());

    fName.getProperties().put("microHelpText", "Enter the first name");
    lName.getProperties().put("microHelpText", "Enter the last name");
    salary.getProperties().put("microHelpText", "Enter a salary greater than $2000.00.");

    // The help text node is unmanaged
    helpText.setManaged(false);//from w w w.  j  a v  a  2 s  .c  o m
    helpText.setTextOrigin(VPos.TOP);
    helpText.setFill(Color.RED);
    helpText.setFont(Font.font(null, 9));
    helpText.setMouseTransparent(true);

    // Add all nodes to a GridPane
    GridPane root = new GridPane();

    root.add(new Label("First Name:"), 1, 1);
    root.add(fName, 2, 1);
    root.add(new Label("Last Name:"), 1, 2);
    root.add(lName, 2, 2);

    root.add(new Label("Salary:"), 1, 3);
    root.add(salary, 2, 3);
    root.add(closeBtn, 3, 3);
    root.add(helpText, 4, 3);

    Scene scene = new Scene(root, 300, 100);

    // Add a change listener to the scene, so we know when
    // the focus owner changes and display the micro help   
    scene.focusOwnerProperty().addListener((ObservableValue<? extends Node> value, Node oldNode,
            Node newNode) -> focusChanged(value, oldNode, newNode));
    stage.setScene(scene);
    stage.setTitle("Showing Micro Help");
    stage.show();
}

From source file:eu.over9000.skadi.ui.dialogs.UpdateAvailableDialog.java

public UpdateAvailableDialog(RemoteVersionResult newVersion) {
    super(AlertType.INFORMATION, null, UPDATE_BUTTON_TYPE, IGNORE_BUTTON_TYPE);

    this.setTitle("Update available");
    this.setHeaderText(newVersion.getVersion() + " is available");

    Label lbChangeLog = new Label("Changelog:");
    TextArea taChangeLog = new TextArea(newVersion.getChangeLog());
    taChangeLog.setEditable(false);/*from   www .  j  av  a2  s. c  o m*/
    taChangeLog.setWrapText(true);

    Label lbSize = new Label("Size:");
    Label lbSizeValue = new Label(FileUtils.byteCountToDisplaySize(newVersion.getSize()));

    Label lbPublished = new Label("Published");
    Label lbPublishedValue = new Label(
            ZonedDateTime.parse(newVersion.getPublished()).format(DateTimeFormatter.RFC_1123_DATE_TIME));

    final GridPane grid = new GridPane();
    RowConstraints vAlign = new RowConstraints();
    vAlign.setValignment(VPos.TOP);
    grid.getRowConstraints().add(vAlign);
    grid.setHgap(10);
    grid.setVgap(10);

    grid.add(lbChangeLog, 0, 0);
    grid.add(taChangeLog, 1, 0);
    grid.add(lbPublished, 0, 1);
    grid.add(lbPublishedValue, 1, 1);
    grid.add(lbSize, 0, 2);
    grid.add(lbSizeValue, 1, 2);

    this.getDialogPane().setContent(grid);
}

From source file:Main.java

static Node distantLight() {
    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0f);//from   ww w .java2 s .c o  m
    light.setElevation(30.0f);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0f);

    final Text t = new Text();
    t.setText("Distant Light");
    t.setFill(Color.RED);
    t.setFont(Font.font("null", FontWeight.BOLD, 70));
    t.setX(10.0f);
    t.setY(50.0f);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    final Rectangle r = new Rectangle();
    r.setFill(Color.BLACK);

    Group g = new Group();
    g.getChildren().add(r);
    g.getChildren().add(t);

    g.setTranslateY(460);

    return g;
}

From source file:io.bitsquare.gui.components.paymentmethods.OKPayForm.java

private void addCurrenciesGrid(boolean isEditable) {
    Label label = addLabel(gridPane, ++gridRow, "Supported currencies:", 0);
    GridPane.setValignment(label, VPos.TOP);
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);/*from  w  w  w . ja va 2 s.c o  m*/
    flowPane.setHgap(10);

    if (isEditable)
        flowPane.setId("flow-pane-checkboxes-bg");
    else
        flowPane.setId("flow-pane-checkboxes-non-editable-bg");

    CurrencyUtil.getAllOKPayCurrencies().stream().forEach(e -> {
        CheckBox checkBox = new CheckBox(e.getCode());
        checkBox.setMouseTransparent(!isEditable);
        checkBox.setSelected(okPayAccount.getTradeCurrencies().contains(e));
        checkBox.setMinWidth(60);
        checkBox.setMaxWidth(checkBox.getMinWidth());
        checkBox.setTooltip(new Tooltip(e.getName()));
        checkBox.setOnAction(event -> {
            if (checkBox.isSelected())
                okPayAccount.addCurrency(e);
            else
                okPayAccount.removeCurrency(e);

            updateAllInputsValid();
        });
        flowPane.getChildren().add(checkBox);
    });

    GridPane.setRowIndex(flowPane, gridRow);
    GridPane.setColumnIndex(flowPane, 1);
    gridPane.getChildren().add(flowPane);
}

From source file:Main.java

private GridPane createGridPane() {
    final GridPane gp = new GridPane();
    gp.setPadding(new Insets(10));
    gp.setHgap(20);//www.  ja v  a 2  s .com
    //gp.add(albumCover, 0, 0, 1, GridPane.REMAINING);
    gp.add(title, 1, 0);
    gp.add(artist, 1, 1);
    gp.add(album, 1, 2);
    gp.add(year, 1, 3);

    final ColumnConstraints c0 = new ColumnConstraints();
    final ColumnConstraints c1 = new ColumnConstraints();
    c1.setHgrow(Priority.ALWAYS);
    gp.getColumnConstraints().addAll(c0, c1);

    final RowConstraints r0 = new RowConstraints();
    r0.setValignment(VPos.TOP);
    gp.getRowConstraints().addAll(r0, r0, r0, r0);

    return gp;
}

From source file:Main.java

@Override
public void start(Stage stage) {

    String message = "Earthrise at Christmas: " + "[Forty] years ago this Christmas, a turbulent world "
            + "looked to the heavens for a unique view of our home "
            + "planet. This photo of Earthrise over the lunar horizon "
            + "was taken by the Apollo 8 crew in December 1968, showing "
            + "Earth for the first time as it appears from deep space. "
            + "Astronauts Frank Borman, Jim Lovell and William Anders "
            + "had become the first humans to leave Earth orbit, "
            + "entering lunar orbit on Christmas Eve. In a historic live "
            + "broadcast that night, the crew took turns reading from "
            + "the Book of Genesis, closing with a holiday wish from "
            + "Commander Borman: \"We close with good night, good luck, "
            + "a Merry Christmas, and God bless all of you -- all of " + "you on the good Earth.\"";

    // Reference to the Text
    Text textRef = TextBuilder.create().layoutY(100).textOrigin(VPos.TOP).textAlignment(TextAlignment.JUSTIFY)
            .wrappingWidth(400).text(message).fill(Color.rgb(187, 195, 107))
            .font(Font.font("SansSerif", FontWeight.BOLD, 24)).build();

    // Provides the animated scrolling behavior for the text
    TranslateTransition transTransition = TranslateTransitionBuilder.create().duration(new Duration(75000))
            .node(textRef).toY(-820).interpolator(Interpolator.LINEAR).cycleCount(Timeline.INDEFINITE).build();

    Scene scene = SceneBuilder/*from w ww.  ja v  a  2  s .c  o m*/
            .create().width(516).height(
                    387)
            .root(GroupBuilder.create().children(
                    ImageViewBuilder.create().image(new Image("http://projavafx.com/images/earthrise.jpg"))
                            .build(),
                    ScrollPaneBuilder.create().layoutX(50).layoutY(180).prefWidth(440).prefHeight(85)
                            .hbarPolicy(ScrollBarPolicy.NEVER).vbarPolicy(ScrollBarPolicy.NEVER).pannable(true)
                            .content(textRef).style("-fx-background-color: transparent;").build())
                    .build())
            .build();

    stage.setScene(scene);
    stage.setTitle("Hello Earthrise");
    stage.show();

    // Start the text animation
    transTransition.play();
}