HiEveryone,Javafx를 사용하여 상단에 TextField를 설정하는 방법은 무엇입니까?
나는 Javafx
에 초보자이야 상단에 TextField
을 설정하려고 내가 GridPane
을 사용하고 있습니다. 그래서 나는이 코드를 시도했지만 그것은 나에게 오류를주고 :
소스 코드 :
package sample;
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.VPos;
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;
import javafx.geometry.HPos;
public class Main extends Application {
@Override
public void start (Stage primaryStage){
primaryStage.setTitle("Modern web browser made by Rajendra Arora using JavaFX.");
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.MAX_VALUE);
tf.positionCaret(25);
GridPane sp = new GridPane();
sp.getChildren().add(wv);
GridPane.setConstraints(tf, 1, 0, 0, 0, HPos.CENTER, VPos.CENTER);
Scene scene = new Scene(sp, 600, 500);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
을하지만이 오류가 점점 :
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:894)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:56)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:158)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: rowSpan must be greater or equal to 1, but was 0
at javafx.scene.layout.GridPane.setRowSpan(GridPane.java:346)
at javafx.scene.layout.GridPane.setConstraints(GridPane.java:591)
at sample.Main.start(Main.java:27)
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
... 1 more
는 :(
도움 주시면 감사하겠습니다 도와주세요!
예외를 생성하는 행 (예 : 27 행)을 표시하십시오. –
GridPane.setConstraints (tf, 1, 0, 0, 0, HPos.CENTER, VPos.CENTER)에서 오류를 보여 주세요, ' –