2016-04-22 10 views
-1
import javafx.application.Application; 
import javafx.geometry.Insets; 
import javafx.scene.Scene; 
import javafx.scene.control.Button; 
import javafx.scene.control.Label; 
import javafx.scene.control.TextField; 
import javafx.scene.layout.GridPane; 
import javafx.stage.Stage; 


public abstract class login extends Application 
{ 
    Stage window; 
    public static void main(String arvg[]) 
    { 
     launch(arvg); 
    } 
    @Override 
    public void start(Stage primaryStage) throws Exception 
    { 
     window= primaryStage; 
     window.setTitle("Login"); 

     GridPane grid=new GridPane(); 
     grid.setPadding(new Insets(10,10,10,10)); 
     grid.setVgap(8); 
     grid.setHgap(8); 

     //Label1 
     Label lbl1=new Label("User Name"); 
     GridPane.setConstraints(lbl1,0,0); 

     //label2 
     Label lbl2=new Label("Password"); 
     GridPane.setConstraints(lbl2,0,1); 

     //userinput 
     TextField username=new TextField(); 
     username.setPromptText("UserName"); 
     GridPane.setConstraints(username,1,0); 

     //Password 
     TextField password=new TextField(); 
     password.setPromptText("Password"); 
     GridPane.setConstraints(password,1,1); 

     //login 
     Button button=new Button("Log In"); 
     GridPane.setConstraints(button,0,2); 

     grid.getChildren().addAll(lbl1,lbl2,username,password,button); 
     Scene s=new Scene(grid,300,200); 
     window.setScene(s); 
     window.show(); 

    } 
} 

これは私がそれを実行しようとログインpage.Whenでの例外を示し、それはアプリケーションのコンストラクタで例外とスレッド「メイン」は、Javaの例外のようなエラーの多くを示しています。 lang.RuntimeException:アプリケーションインスタンスを構築できません:クラスログイン com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907) com.sun.javafx.application.LauncherImpl.lambda $ launchApplication $ 155(LauncherImpl .java:182) at java.lang.Thread.run(Thread.java:745) 何が問題なのか分かりません。だから誰でも私がそれを説明することができますか?ありがとう。私はそれを実行し、それはアプリケーションのコンストラクタ

答えて

0

なぜクラスを抽象化しましたか?抽象クラスの場合、アプリケーションはクラスからオブジェクトを作成することはできません。クラス定義からabstractキーワードを削除します。

+0

オハイオ州、助けてくれてありがとう。それは今働いている。 :) –

関連する問題