皆さんこんにちは、
私は新しい JavaFx
と私 TextField
フレームの中央に表示されますが、最上部の位置には表示されません。どこが間違っていると思われますか?plsヘルプ..
このスクリーンショットをご覧ください。
しかし、私は上部にそのTextFieldを設定したい..
ソースコードは次のとおりです。
package sample;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.scene.control.TextField;
public class Main extends Application {
@Override
public void start (Stage primaryStage){
primaryStage.setTitle("Modern web browser.");
WebView wv = new WebView();
WebEngine we = wv.getEngine();
we.load("http://www.google.com/");
TextField tf = new TextField("http://www.google.com/");
tf.setMaxHeight(Double.MIN_VALUE);
GridPane sp = new GridPane();
sp.getChildren().add(wv);
sp.getChildren().add(tf);
Scene scene = new Scene(sp, 600, 500);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
助けてください。
EDITED
@Nagesh Kumarが使用した後に私に答えたように VBox
このエラーが発生しました:
回答:
回答№1は1次のように、GridPaneからVBoxにレイアウトを変更します
VBox vbox = new VBox();
次に、最初にTextFieldを追加して、次のように上に表示されるようにします
vbox.getChildren().add(tf);
次のようにWebView
vbox.getChildren().add(wv);
編集: はい、これを試すことができます
VBox vbox = new VBox(5);
VBoxに配置されたコントロール間の5ピクセルのスペース