Hello i'm not that great of a coder. I recently tried out a code showing dxball scenerio which is very simple. There i wanted to print a text as well showing "score:0". I'm giving my code below [It compiles fine, but shows runtime error], on my friends' computer it runs without any error showing the text on the output screen.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
public class dxball extends Application{
public void start(Stage stage){
Group root= new Group();
Scene scene=new Scene(root,700,500);
Text t=new Text(20,20,"Score:0");
t.setFont(Font.font("Verdana", 20));
t.setFill(Color.BLACK);
root.getChildren().add(t);
Circle ball=new Circle(340,455,15);
ball.setFill(Color.CORNFLOWERBLUE);
Rectangle brick1=new Rectangle(200,470,280,30);
brick1.setFill(Color.PALEGREEN);
brick1.setStroke(Color.CYAN);
Rectangle brick2=new Rectangle(100,100,80,40);
brick2.setFill(Color.CORAL);
brick2.setStroke(Color.BLACK);
Rectangle brick3=new Rectangle(200,100,80,40);
brick3.setFill(Color.CORAL);
brick3.setStroke(Color.BLACK);
Rectangle brick4=new Rectangle(300,100,80,40);
brick4.setFill(Color.CORAL);
brick4.setStroke(Color.BLACK);
Rectangle brick5=new Rectangle(400,100,80,40);
brick5.setFill(Color.CORAL);
brick5.setStroke(Color.BLACK);
Rectangle brick6=new Rectangle(500,100,80,40);
brick6.setFill(Color.CORAL);
brick6.setStroke(Color.BLACK);
Rectangle brick7=new Rectangle(250,150,80,40);
brick7.setFill(Color.CYAN);
brick7.setStroke(Color.BLACK);
Rectangle brick8=new Rectangle(350,150,80,40);
brick8.setFill(Color.CYAN);
brick8.setStroke(Color.BLACK);
root.getChildren().add(brick1);
root.getChildren().add(brick2);
root.getChildren().add(brick3);
root.getChildren().add(brick4);
root.getChildren().add(brick5);
root.getChildren().add(brick6);
root.getChildren().add(brick7);
root.getChildren().add(brick8);
root.getChildren().add(ball);
stage.setTitle("Untitled");
stage.setScene(scene);
stage.show();
}
}
Please help :( i'm attaching the pic when i try to run the code what appears enter image description here