0

how could i create lines by using array? javafx

I am trying to create some lines by using an array but i couldn't complier it. just gives me several exceptions. Anyone could help me with the idea? public class Dotgame extends Application { @Override public void start(Stage primaryStage) { //creating array of circles; Circle[] circle=new Circle[9]; Line[] line=new Line[12]; int cCount=0; int lCount=0; //assign the lines for(int i=0;i<9;i++) { line[i].setStartX(circle[i].getTranslateX()); line[i].setStartY(circle[i].getTranslateY()); line[i].setEndX(circle[i+1].getTranslateX()); line[i].setEndY(circle[i+1].getTranslateY()); } //assign the size of circles; for(int i=0;i<9;i++) { circle[i]=new Circle(10); } //assign the X,Y of the circles; for(int i=100;i<400;i+=100) { for(int j=100;j<400;j+=100) { circle[cCount].setTranslateX(i); circle[cCount].setTranslateY(j); cCount++; } } Group group=new Group(line); StackPane root = new StackPane(); root.setAlignment(Pos.TOP_LEFT); root.getChildren().addAll(circle); root.getChildren().addAll(line); Scene scene = new Scene(root, 500, 500); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }

21st Nov 2018, 4:42 AM
Jimmy Chen
Jimmy Chen  - avatar
1 Odpowiedź
0
Please post those 'several exceptions'. This could help to understand your problem.
7th Dec 2018, 12:55 PM
Tom Dooley
Tom Dooley - avatar