错误:错误:无法找到或加载主类neon.Main

时间:2018-05-21 16:17:05

标签: java javafx

我正在编写应用程序,但我收到了标题中指定的错误消息。在src文件夹下的包是氖类Main.java。 neon.friends包中包含Friends.fxml。包neon.views包含MainItemsController.java,MainItems.fxml和MainView.fxml。

以下是主要类的代码:

    package neon;

import java.io.IOException;


import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Main extends Application {

private Stage primaryStage;
private static  BorderPane mainLayout;

@Override
public void start(Stage primaryStage) throws IOException {
    this.primaryStage = primaryStage;
    this.primaryStage.setTitle("Neon");
    showMainView();
    showMainItems();
}

private void showMainView() throws IOException{
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Main.class.getResource("view/MainView.fxml"));
    mainLayout = loader.load();
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
}

private void showMainItems() throws IOException{
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Main.class.getResource("view/MainItems.fxml"));
    BorderPane mainItems = loader.load();
    mainLayout.setCenter(mainItems);
}

public static void showFriends() throws IOException{
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Main.class.getResource("friends/Friends.fxml"));
    BorderPane friends = loader.load();
    mainLayout.setCenter(friends);
}

public static void main(String[] args) {
    launch(args);
}
}

0 个答案:

没有答案