java - 如何改变这个按钮的 float ?

标签 java mysql javafx

大家好,

我是新的 Javafx,并尝试将此按钮的 float 从当前左侧更改为右侧。如何做到这一点?

我目前仅使用 Pane 作为容器。

看看这个屏幕截图:

enter image description here

如何做到这一点? ..请帮助

提前致谢!

已编辑

源代码:

package sample;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.scene.control.TextField;
import javafx.scene.control.Button;

public class Main extends Application {

    @Override
    public void start (Stage primaryStage){
        primaryStage.setTitle("Modern web browser made by Rajendra arora.");
        WebView wv = new WebView();
        wv.setLayoutX(0.0);
        wv.setLayoutY(40.0);
        wv.setPrefHeight(Double.MAX_EXPONENT);
        wv.setPrefWidth(Double.MAX_EXPONENT);
        WebEngine we = wv.getEngine();
        we.load("http://www.google.com/");

        Button btn=new Button("Go");


        TextField tf = new TextField("http://www.google.com/");
        tf.setLayoutX(1.0);
        tf.setPrefWidth(Double.MAX_EXPONENT);
        tf.setPrefHeight(25.0);

        Pane sp = new Pane();
        sp.getChildren().add(tf);
        sp.getChildren().add(btn);
        sp.getChildren().add(wv);

        Scene scene = new Scene(sp, 600, 500);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

最佳答案

使用 HBox 保存文本字段和按钮,稍后将其添加到 Pane

HBox hbox = new HBox();
hbox.getChildren().addAll(tf, btn);
Pane sp = new Pane();
sp.getChildren().add(hbox);
sp.getChildren().add(wv);

关于java - 如何改变这个按钮的 float ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25698557/

相关文章:

java - 如何通过JRuby在SWT/Shoes中获得macOS透明标题栏效果

java - 我如何将文件从 sdcard 上传到 Android 中的 SFTP 服务器?

mysql - 调用mysql后express-http-context丢失

css - javafx按钮悬停时隐藏文本的一部分

java - 如何在 main 中使用我自己的类?

java使用注解和aop发送电子邮件

java - GWT 和 web.xml

php - mysql 已死,但 subsys 已锁定

mysql - SQL Reporting Services 中 MySql 查询的日期语法

java - 如何为 ControlsFX CustomTextField 自动完成下拉列表设置 OnClick 或 OnSelection?