0

Eclipse doesn't show any problem or a red line, but the app still doesn't run, what should I do?

here is the code: package application; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.effect.DropShadow; import javafx.scene.effect.Reflection; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Rectangle; import javafx.scene.text.Font; import javafx.scene.text.Text; public class Main extends Application { public void start(Stage primaryStage) { Group root= new Group(); Scene scene= new Scene(root,600,600,Color.DARKGRAY); Line line=new Line(); line.setStartX(125); line.setStartY(103); line.setEndX(400); line.setEndY(206); root.getChildren().add(line); Rectangle rec= new Rectangle(); rec.setX(400); rec.setY(400); rec.setWidth(100); rec.setHeight(100); rec.setFill(Color.YELLOW); rec.setArcHeight(50); rec.setArcWidth(100); root.getChildren().add(rec); Image img= new Image(getClass().getResourceAsStream("bu1.png")); Button btn= new Button(); btn.setGraphic(new ImageView(img)); btn.setLayoutX(250); btn.setLayoutY(400); Label lbl=new Label("Rotation angle: "); lbl.setLayoutX(250); lbl.setLayoutY(375); root.getChildren().addAll(btn,lbl); DropShadow shadow= new DropShadow(); btn.addEventHandler(MouseEvent.MOUSE_ENTERED, (MouseEvent e)->{ btn.setEffect(shadow); }); btn.addEventHandler(MouseEvent.MOUSE_EXITED, (MouseEvent e)->{ btn.setEffect(null); }); Text txt=new Text(120,150,"Welcome to JavaFX"); Font fnt=new Font("century gothic",30); txt.setFont(fnt); txt.setFill(Color.YELLOW); txt.setRotate(20); root.getChildren().add(txt);

14th Sep 2020, 9:17 AM
Ayman
Ayman - avatar
2 Antworten
+ 2
Your code is truncated due to being longer than the limit that was allowed for Description. Save your code in SoloLearn, and share the saved code link in your thread's Description. That way people can check the full code, and hopefully assist you through this. Follow the below guide to share links 👇 https://www.sololearn.com/post/75089/?ref=app
14th Sep 2020, 9:49 AM
Ipang
0
when I click on run , console shows this Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) at java.base/java.lang.Thread.run(Thread.java:832) Caused by: java.lang.NullPointerException: Input stream must not be null at javafx.graphics/javafx.scene.image.Image.validateInputStream(Image.java:1135) at javafx.graphics/javafx.scene.image.Image.<init>(Image.java:702) at application.Main.start(Main.java:46) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$1
14th Sep 2020, 9:18 AM
Ayman
Ayman - avatar