0
私は2時間のような問題に取り組んでいます。私はまだそれを修正できません。 私の仕事は、49のRectangel Squaresをプログラムすることです。 ので、私はそれを容易にするために、配列を使用しようとしましたが、それは仕事をしたいdoen'st: '(JavaFX Rectangel Arrayは動作しません
それが動作配列を使用しなくても...
が助けてくれてありがとう
ソースコードを! :
package Game;
import javafx.scene.shape.Rectangle;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Game extends Application{
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
VBox vb = new VBox();
VBox vb2 = new VBox();
HBox hb = new HBox();
Rectangle q[] = new Rectangle[4];
q[0].setFill(Color.RED);
q[1].setFill(Color.BLUE);
q[2].setFill(Color.GREEN);
q[3].setFill(Color.YELLOW);
vb.getChildren().addAll(q[0],q[1]);
vb2.getChildren().addAll(q[2],q[3]);
hb.getChildren().addAll(vb,vb2);
Scene sz1 = new Scene(hb);
primaryStage.setScene(sz1);
primaryStage.show();
}
}
my compiler :
> 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)
atcom.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Launcher
Impl.java:389)
atcom.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.jav
a:328)
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
atcom.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.ja
va:917)
atcom.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(Launc
herImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at Spiel.FensterSpiel.start(FensterSpiel.java:29)
atcom.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(Laun
cherImpl.java:863)
atcom.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl
.java:326)
atcom.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:
295)
at java.security.AccessController.doPrivileged(Native Method)
atcom.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.j
ava:294)
atcom.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.ja
va:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
atcom.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:19
1)
... 1 more