javaFX应用程序启动错误

时间:2013-11-25 15:09:14

标签: javafx-2

我刚开始使用javaFX,最近在通过Eclipse运行应用程序时遇到了以下错误。 我的代码:

import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class WindowBetaV02 extends AbstractWindow{

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

    public void start(Stage mainStage){
        height = 480;
        width = 640;
        mainStage = new Stage();
        mainStage.setTitle("AMQ");
        mainStage.setScene(drawGUIGameNormal());
        mainStage.setResizable(false);
        mainStage.show();
    }

    private Scene drawGUIGameNormal(){
        //Draw gui
    }
}

import javafx.application.Application;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.RowConstraints;
import javafx.stage.Stage;

public abstract class AbstractWindow extends Application {
    protected int height;
    protected int width;
    protected GameFunctions controller;

    public abstract void start(Stage stage);

    protected GridPane createPlayerPane(int width, int height){
        GridPane playerPane = createPixelGridPane(width, height);
        playerPane.getStyleClass().add("playerPane");       
        playerPane.add(createPlayerTable(), 10, 10, width-10, width-10);
        return playerPane;
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected TableView createPlayerTable(){
        TableView table = new TableView();
        TableColumn points = new TableColumn("Points");
        points.setMaxWidth(30);
        points.setMinWidth(30);
        points.setCellFactory(new PropertyValueFactory<Players, Integer>("points"));

        TableColumn player = new TableColumn("Player");
        player.setMaxWidth(100);
        player.setMinWidth(100);
        player.setCellFactory(new PropertyValueFactory<Players, String>("playerName")); 

        table.setItems(controller.getPlayers());
        table.getColumns().addAll(player, points);

        return table;
    }

    protected GridPane createPixelGridPane(int width, int height){
        GridPane pane = new GridPane();
        for(int i = 0; i < width; i++){
            pane.getColumnConstraints().add(new ColumnConstraints(1));
        }
        for(int i = 0; i < height; i++){
            pane.getRowConstraints().add(new RowConstraints(1));
        }
        return pane;
    }
}

错误

Exception in thread "main" java.lang.RuntimeException: Application launch error
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:122)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.win.WinApplication._invokeLater(Ljava/lang/Runnable;)V
    at com.sun.glass.ui.win.WinApplication._invokeLater(Native Method)
    at com.sun.glass.ui.Application.invokeLater(Application.java:338)
    at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:620)
    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:173)
    at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:212)
    at com.sun.javafx.application.PlatformImpl.tkExit(PlatformImpl.java:320)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:421)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    ... 1 more

任何人都知道如何解决此错误?

-Edit-

添加了AbstractWindow类的代码

1 个答案:

答案 0 :(得分:3)

您使用的是JavaFx,您的主类必须扩展Application而不是Window