Java Code Examples for javafx.scene.control.Button#setTranslateY()

The following examples show how to use javafx.scene.control.Button#setTranslateY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: View.java    From FXTutorials with MIT License 6 votes vote down vote up
public View(Controller controller) {
    this.controller = controller;

    setPrefSize(635 * 2, 500);

    Image image = new Image("http://cdn.ndtv.com/tech/windows_10_startmenu_cropped.jpg");
    ImageView originalView = new ImageView(image);

    ImageView modifiedView = new ImageView();
    modifiedView.setTranslateX(635);

    TextField field = new TextField("Enter message");
    field.setTranslateY(454);
    field.setOnAction(e -> controller.onEncode());

    Button btnDecode = new Button("DECODE");
    btnDecode.setTranslateX(635);
    btnDecode.setTranslateY(454);
    btnDecode.setOnAction(e -> controller.onDecode());

    controller.injectUI(originalView, modifiedView, field);

    getChildren().addAll(originalView, modifiedView, field, btnDecode);
}
 
Example 2
Source File: Main.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(800, 600);

    Dice dice1 = new Dice();
    Dice dice2 = new Dice();

    dice1.setTranslateX(100);
    dice1.setTranslateY(200);

    dice2.setTranslateX(300);
    dice2.setTranslateY(200);

    Button btn = new Button("New target");
    btn.setOnAction(event -> {
        target.set((int)(Math.random() * (Dice.MAX_VALUE * 2 + 1)));
    });

    btn.setTranslateX(400);
    btn.setTranslateY(200);

    SimpleBooleanProperty bool = new SimpleBooleanProperty();
    bool.bind(target.isEqualTo(dice1.valueProperty.add(dice2.valueProperty)));

    Text message = new Text();
    message.textProperty().bind(target.asString().concat(bool.asString()));

    message.setTranslateX(500);
    message.setTranslateY(200);

    root.getChildren().addAll(dice1, dice2, btn, message);
    return root;
}
 
Example 3
Source File: DialogsApp.java    From FXTutorials with MIT License 4 votes vote down vote up
CustomDialog(String header, String content) {
    Pane root = new Pane();

    scale1.setFromX(0.01);
    scale1.setFromY(0.01);
    scale1.setToY(1.0);
    scale1.setDuration(Duration.seconds(0.33));
    scale1.setInterpolator(EXP_IN);
    scale1.setNode(root);

    scale2.setFromX(0.01);
    scale2.setToX(1.0);
    scale2.setDuration(Duration.seconds(0.33));
    scale2.setInterpolator(EXP_OUT);
    scale2.setNode(root);

    initStyle(StageStyle.TRANSPARENT);
    initModality(Modality.APPLICATION_MODAL);

    Rectangle bg = new Rectangle(350, 150, Color.WHITESMOKE);
    bg.setStroke(Color.BLACK);
    bg.setStrokeWidth(1.5);

    Text headerText = new Text(header);
    headerText.setFont(Font.font(20));

    Text contentText = new Text(content);
    contentText.setFont(Font.font(16));

    VBox box = new VBox(10,
            headerText,
            new Separator(Orientation.HORIZONTAL),
            contentText
    );
    box.setPadding(new Insets(15));

    Button btn = new Button("OK");
    btn.setTranslateX(bg.getWidth() - 50);
    btn.setTranslateY(bg.getHeight() - 50);
    btn.setOnAction(e -> closeDialog());

    root.getChildren().addAll(bg, box, btn);

    setScene(new Scene(root, null));
}