[英]A java.lang.NoSuchMethodException error (layouts)
我想在另一個窗口中顯示另一個布局,但是每當我添加新布局到start方法時
BorderPane sch = new BorderPane();
sch.setCenter(addVBox2(primaryStage));
scene1 = new Scene(sch, 800, 500);
我得到這個錯誤
應用程序啟動方法異常
Exception in thread "main" **java.lang.NoSuchMethodException**: sample.Main.main([Ljava.lang.String;)
at java.lang.Class.getMethod(Class.java:1786)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:119)
代碼中的問題可能在哪里? 感謝您的任何幫助。
public void start(Stage primaryStage) throws IOException {
stage = primaryStage;
BorderPane border = new BorderPane();
border.setLeft(addVBox(primaryStage));
border.setCenter(addGridPane(primaryStage));
border.setRight(addDatePicker(primaryStage));
HBox hbox = addHBox();
border.setBottom(hbox);
scene = new Scene(border, 800, 500);
BorderPane sch = new BorderPane();
sch.setCenter(addVBox2(primaryStage));
scene1 = new Scene(sch, 800, 500);
stage.setScene(scene);
stage.setTitle("Booking Form");
stage.show();
}
private VBox addVBox2(Stage stage) {
javafx.scene.control.Label label = new javafx.scene.control.Label("Choose rooms' schedule");
label.setFont(javafx.scene.text.Font.font("Tahoma", FontWeight.BOLD, 16));
room1 = new RadioButton("Room 1 of type 1");
room1.setSelected(true);
room2 = new RadioButton("Room 2 of type 1");
room3 = new RadioButton("Room 1 of type 2");
room4 = new RadioButton("Room 2 of type 2");
room5 = new RadioButton("Room 1 of type 3");
room6 = new RadioButton("Room 2 of type 3");
VBox buttons2 = new VBox(20, label, roomtype1, roomtype2);
buttons2.setAlignment(Pos.CENTER);
buttons2.setMaxWidth(225);
stackPane.getChildren().add(buttons2);
ToggleGroup toggleGroup = new ToggleGroup();
toggleGroup.getToggles().addAll(roomtype1, roomtype2);
Scene scene = new Scene(stackPane, 400, 200);
stage.setTitle("RadioButton control");
stage.setScene(scene);
stage.show();
return buttons2;
}
private HBox addHBox() {
HBox hbox = new HBox();
hbox.setPadding(new Insets(15, 12, 15, 12));
hbox.setSpacing(10); // Gap between nodes
hbox.setStyle("-fx-background-color: #336699;");
hbox.setAlignment(Pos.CENTER);
final Text actionTarget = new Text();
Button schedule = new Button("Schedule");
schedule.setPrefSize(100, 20);
schedule.setOnAction(e -> stage.setScene(scene1));
...}
Exception in thread "main" java.lang.NoSuchMethodException: Main.main([Ljava.lang.String;)
此錯誤意味着找不到您的主類。 當您遇到此類錯誤時,大多數情況下,這意味着您將主類從文件移動到了另一個文件而沒有更改運行配置。
在intellij IDE中編輯您的運行配置。 您的運行配置似乎指向錯誤的類。 編輯運行配置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.