无法运行javaFX

时间:2014-09-14 13:09:00

标签: javafx

它工作得很好然后突然我得到了这个错误

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(Unknown Source)
    at com.sun.javafx.application.LauncherImpl$$Lambda$48/21122690.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
    at java.nio.HeapByteBuffer.<init>(Unknown Source)
    at java.nio.ByteBuffer.allocate(Unknown Source)
    at com.sun.javafx.iio.png.PNGImageLoader2.load(Unknown Source)
    at com.sun.javafx.iio.ImageStorage.loadAll(Unknown Source)
    at com.sun.javafx.iio.ImageStorage.loadAll(Unknown Source)
    at com.sun.javafx.tk.quantum.PrismImageLoader2.loadAll(Unknown Source)
    at com.sun.javafx.tk.quantum.PrismImageLoader2.<init>(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.loadImage(Unknown Source)
    at javafx.scene.image.Image.loadImage(Unknown Source)
    at javafx.scene.image.Image.initialize(Unknown Source)
    at javafx.scene.image.Image.<init>(Unknown Source)
    at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(Unknown Source)
    at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(Unknown Source)
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source)
    at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at application.Main.start(Main.java:18)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
    at com.sun.javafx.application.LauncherImpl$$Lambda$51/32359153.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/11567059.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/4247839.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
Exception running application application.Main

它指向我的主要课程

package application;

import java.net.URL;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import connection.Conexiune;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {


            Parent root = FXMLLoader.load(getClass().getResource(
                    "/application/MyView.fxml"));
            Scene scene = new Scene(root);
            scene.getStylesheets().add(
                    getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);

            primaryStage.setTitle("StarMap v7.5");


            primaryStage.show();
            setUserAgentStylesheet(STYLESHEET_CASPIAN);

            Conexiune.createConnection();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

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

更确切地说这行我不知道为什么因为它工作正常直到现在我所做的是使用场景构建器将另一个imageview添加到界面

Parent root = FXMLLoader.load(getClass().getResource("/application/MyView.fxml"));

任何人都可以帮助我吗?

这是我的FXML

 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane fx:id="aPane" centerShape="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" scaleShape="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.MyController">
   <effect>
      <Blend />
   </effect>
   <children>
      <Pane fx:id="secPane" prefHeight="800.0" prefWidth="1280.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <children>
            <ComboBox fx:id="ora" layoutX="14.0" layoutY="217.0" prefHeight="25.0" prefWidth="174.0" promptText="Selectati ora" visible="false" />
            <DatePicker fx:id="data" layoutX="14.0" layoutY="127.0" promptText="Selectati data" />
            <Pane fx:id="imgPaneIanuarie" layoutX="200.0" layoutY="14.0" prefHeight="692.0" prefWidth="1066.0" style="-fx-background-color: black;" visible="false">
               <children>
                  <ImageView fx:id="sMap" fitHeight="692.0" fitWidth="1066.0" layoutX="-1.0" pickOnBounds="true" preserveRatio="true" />
                  <ImageView fx:id="Sirius" fitHeight="16.0" fitWidth="15.0" layoutX="335.0" layoutY="433.0" onMouseClicked="#getInfoSirius" onMouseEntered="#mouseEnteredSirius" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/sirius.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Procyon" fitHeight="12.0" fitWidth="11.0" layoutX="284.0" layoutY="319.0" onMouseClicked="#getInfoProcyon" onMouseEntered="#mouseEnteredProcyon" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/procyon.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Beetlegeuse" fitHeight="13.0" fitWidth="13.0" layoutX="402.0" layoutY="319.0" onMouseClicked="#getInfoBetelgeuse" onMouseEntered="#mouseEnteredBeetlegeuse" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/beetlegeuse.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Rigel" fitHeight="12.0" fitWidth="13.0" layoutX="450.0" layoutY="398.0" onMouseClicked="#getInfoRigel" onMouseEntered="#mouseEnteredRigel" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/rigel.png" />
                     </image></ImageView>
                  <ImageView fx:id="Capella" fitHeight="18.0" fitWidth="16.0" layoutX="449.0" layoutY="126.0" onMouseClicked="#getInfoCapella" onMouseEntered="#mouseEnteredCapella" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/capella.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Aldebaran" fitHeight="9.0" fitWidth="10.0" layoutX="497.0" layoutY="281.0" onMouseClicked="#getInfoAldebaran" onMouseEntered="#mouseEnteredAldebaran" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/aldebaran.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Polux" fitHeight="10.0" fitWidth="11.0" layoutX="297.0" layoutY="213.0" onMouseClicked="#getInfoPollux" onMouseEntered="#mouseEnteredPolux" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/polux.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Castor" fitHeight="7.0" fitWidth="6.0" layoutX="314.0" layoutY="199.0" onMouseClicked="#getInfoCastor" onMouseEntered="#mouseEnteredCastor" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/castor.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Regulus" fitHeight="8.0" fitWidth="8.0" layoutX="14.0" layoutY="229.0" onMouseClicked="#getInfoRegulus" onMouseEntered="#mouseEnteredRegulus" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/regulus.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="Mirphak" fitHeight="10.0" fitWidth="10.0" layoutX="579.0" layoutY="54.0" onMouseClicked="#getInfoMirfak" onMouseEntered="#mouseEnteredMirphak" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../Img/mirphak.png" />
                     </image>
                  </ImageView>
                  <Label layoutX="511.0" layoutY="6.0" prefHeight="35.0" prefWidth="35.0" text=" N" textAlignment="JUSTIFY" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <Label layoutX="508.0" layoutY="643.0" prefHeight="35.0" prefWidth="35.0" text="  S" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <Label layoutX="1017.0" layoutY="338.0" prefHeight="35.0" prefWidth="35.0" text=" W" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <Label layoutX="14.0" layoutY="329.0" prefHeight="35.0" prefWidth="35.0" text="  E" textFill="#fc0f0f">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="debug" fitHeight="5.0" fitWidth="5.0" layoutX="487.0" layoutY="438.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/red.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos1" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="1027.0" layoutY="653.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos2" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="964.0" layoutY="658.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos3" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="1010.0" layoutY="636.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos4" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="794.0" layoutY="494.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos5" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="233.0" layoutY="419.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos6" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="84.0" layoutY="434.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="nodePos7" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="84.0" layoutY="434.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/halo.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="infoSirius" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="14.0" layoutY="578.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/blueStar.gif" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameSirius" contentDisplay="CENTER" disable="true" layoutX="14.0" layoutY="556.0" lineSpacing="5.0" prefHeight="25.0" prefWidth="100.0" text="Sirius" textAlignment="JUSTIFY" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoBetlegeuse" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="115.0" layoutY="592.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/redStar.gif" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameBetelgeuse" disable="true" layoutX="114.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Betlegeuse" textAlignment="CENTER" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="19.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoMirfak" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="213.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/mirphakStar.png" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameMirfak" disable="true" layoutX="219.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Mirfak" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoProcyon" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="285.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/mirphakStar.png" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameProcyon" disable="true" layoutX="284.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Procyon" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <Label fx:id="sNamePolux" disable="true" layoutX="371.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Pollux" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoPolux" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="372.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/poluxStar.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="infoCapella" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="547.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/capellaStar.png" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameCapella" disable="true" layoutX="546.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Capella" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <Label fx:id="sNameRegulus" disable="true" layoutX="628.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Regulus" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoRegulus" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="629.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/regulusStar.png" />
                     </image>
                  </ImageView>
                  <ImageView fx:id="infoAldebaran" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="719.0" layoutY="578.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/aldebaranstar.gif" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameAldebaran" disable="true" layoutX="719.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Aldebaran" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoRigel" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="838.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/rigeStar.png" />
                     </image>
                  </ImageView>
                  <Label fx:id="sNameRigel" disable="true" layoutX="837.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Rigel" textFill="WHITE" underline="true" visible="false">
                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
                  <ImageView fx:id="infoCastor" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="952.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
                     <image>
                        <Image url="@../../Img/castorStar.png" />
                     </image>
                  </ImageView>


                     <font>
                        <Font name="System Bold" size="20.0" />
                     </font>
                  </Label>
               </children></Pane>
         </children>
      </Pane>
   </children>
</AnchorPane>

0 个答案:

没有答案
相关问题