-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:無法構造應用程序實例:class login at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907) at com.sun.javafx.application.LauncherImpl.lambda $ launchApplication $ 155(LauncherImpl .java:182) at java.lang.Thread.run(Thread.java:745) 我不知道是什麼問題。所以任何人都可以解釋或幫助我解決它?謝謝。,它表示的是適用的構造
哦,謝謝你的幫助。它正在工作。 :) –