2014-09-05 5 views
0

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 

는 :(

도움 주시면 감사하겠습니다 도와주세요!

+0

예외를 생성하는 행 (예 : 27 행)을 표시하십시오. –

+0

GridPane.setConstraints (tf, 1, 0, 0, 0, HPos.CENTER, VPos.CENTER)에서 오류를 보여 주세요, ' –

답변

0

오류 메시지는 매우 명확합니다.메서드를 호출하고 있습니다.이고 rowSpancolSpan에 0을 전달합니다. 오류 메시지는 rowSpan을 0으로 설정할 수 없다고 말합니다. (아마도 colSpan을 0으로 설정할 수 없을 것입니다.) 이러한 제한은 이해가가는 것처럼 보입니다.

+0

알았어 .. 네가 맞았 어 .. .. 고맙다. 사실 .. 프레임 안의 TextField를 볼 수 없습니다. pls .. –

+0

격자 창에 텍스트 필드를 추가하는 것을 잊었습니다. –

+0

하지만 여기서'tf'를 볼 수 있습니다 ...'GridPane.setConstraints (tf, 1, 0, 0, 0, HPos.CENTER, VPos.CENTER); ' –

관련 문제