Eclipse でJavaFXを勉強しています。
以下のグラデーションのプログラムを実行しても、参考書の通りに表示されません。
画面が出てこない状態です。コードの打ち間違いを何回もチェックしたのですが、
うまくいきません。
エラー情報は見てもよくわかりません。以下がエラーです。
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Invalid gradient specification, must end with ")"
at javafx.scene.paint.RadialGradient.valueOf(RadialGradient.java:431)
at errorFiles.Gradient.start(Gradient.java:49)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Exception running application errorFiles.Gradient
よろしくお願いいたします。
package errorFiles; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.RadialGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class Gradient extends Application { //@Override public void start(Stage stage){ stage.setTitle("Gradient"); stage.setWidth(360); stage.setHeight(380); Rectangle rect1 = new Rectangle(); rect1.setWidth(220); rect1.setHeight(50); Stop[] stops1 = new Stop[] { new Stop(0,Color.BLACK), new Stop(1,Color.RED)}; LinearGradient lg1 = new LinearGradient(0, 0, 1, 0,true, CycleMethod.NO_CYCLE, stops1); rect1.setFill(lg1); Rectangle rect2 = new Rectangle(); rect2.setWidth(220); rect2.setHeight(50); Stop[] stops2 = new Stop[] { new Stop(0, Color.LIGHTSTEELBLUE), new Stop(1, Color.PALEGREEN)}; LinearGradient lg2 = new LinearGradient(0, 0, 0.25, 0.25,true, CycleMethod.REFLECT, stops2); rect2.setFill(lg2); Rectangle rect3 = new Rectangle(); rect3.setWidth(200); rect3.setHeight(200); RadialGradient rg = RadialGradient.valueOf("radial-gradient(center 100px 100px,radius 200px ,red 0%,blue 30%,black 100%) "); //radial-gradient円形グラデーションを指定する rect3.setFill(rg); VBox root = new VBox(); root.setSpacing(10); root.getChildren().addAll(rect1,rect2,rect3); Scene scene = new Scene(root,300,200); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/09/04 04:50
2018/09/04 04:56 編集
退会済みユーザー
2018/09/04 04:59
2018/09/04 09:13
退会済みユーザー
2018/09/04 11:27