This is probably what you want to do: package com.mycompany.mavenproject22;
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.shape.Rectangle; /** * JavaFX App */ public class App extends Application { @Override public void start(Stage primaryStage) { double WIDTH = 200; double HEIGHT = 200; // create a pane Pane pane = new Pane(); for (int i = 0; i < 8; i++) { boolean isWhite = i % 2 == 0; for (int j = 0; j < 8; j++) { Rectangle rectangle = new Rectangle(i * WIDTH / 8, j * HEIGHT / 8, WIDTH / 8, HEIGHT / 8); rectangle.setStroke(Color.BLACK); if (isWhite) { rectangle.setFill(Color.WHITE); } else { rectangle.setFill(Color.BLACK); } isWhite = !isWhite; pane.getChildren().add(rectangle); } // end of inner for loop } // end of outer for loop // create scene Scene scene = new Scene(pane, WIDTH, HEIGHT); primaryStage.setTitle("Display A CheckBoard"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(); } } Thanks, Gj On Mon, Jul 6, 2020 at 11:10 AM Geertjan Wielenga <geert...@apache.org> wrote: > You're creating a scene at the end of some kind of nested for loop? > > Gj > > On Mon, Jul 6, 2020 at 10:54 AM Brain Rebooting <siumastroma...@gmail.com> > wrote: > >> OK. Here I am going to submit my simple source code of JavaFX program, >> that should show a black and white chessboard. >> >> >> ------------------------------------------------------------------------------------------------------------------------------------------------ >> >> >> import javafx.application.Application; >> import javafx.scene.Scene; >> import javafx.scene.layout.Pane; >> import javafx.scene.paint.Color; >> import javafx.stage.Stage; >> import javafx.scene.shape.Rectangle; >> >> /** >> * >> * @author samiul alom sium >> * date: 07.07.2020 >> * >> * problem: (Game: display a checkerboard) Write a program that displays >> * a checkerboard in which each white and black cell is a Rectangle >> * with a fill color black or white. >> */ >> >> public class DisplayACheckBoard extends Application { >> >> @Override >> public void start(Stage primaryStage) { >> >> double WIDTH = 200; >> double HEIGHT = 200; >> >> // create a pane >> Pane pane = new Pane(); >> >> for(int i = 0; i < 8; i++){ >> boolean isWhite = i % 2 == 0; >> for(int j = 0; j < 8; j++){ >> Rectangle rectangle = new Rectangle(i * WIDTH / 8, >> j * HEIGHT / 8, WIDTH / 8, HEIGHT / 8); >> >> rectangle.setStroke(Color.BLACK); >> >> if(isWhite){ >> rectangle.setFill(Color.WHITE); >> } >> else { >> rectangle.setFill(Color.BLACK); >> } >> >> isWhite = !isWhite; >> >> pane.getChildren().add(rectangle); >> >> // create scene >> Scene scene = new Scene(pane, WIDTH, HEIGHT); >> primaryStage.setTitle("Display A CheckBoard"); >> primaryStage.setScene(scene); >> primaryStage.show(); >> >> } // end of inner for loop >> } // end of outer for loop >> >> } >> >> public static void main(String[] args) { >> launch(args); >> >> >> ------------------------------------------------------------------------------------------------------------------------------------------------------ >> >> Here I used: >> >> JDK: amazon corretto 1.8.0 252 >> OS: Ubuntu 18.04.4 LTS >> IDE: Apache NetBeans 12 >> Build Tool: Ant >> >> // >> Extra info: >> Even netbeans-12 error detector didn't show any error on the above code. >> Problem arises when I am going to run the code. I try to clean and build >> projects and then run the projects, but still same results come in. But the >> strange thing is, this same source code works in IntelliJ IDEA community >> edition with same compiler. Even I can't remember I could see any GUI >> result of my JavaFX program in NB-12, but I could do that well in NB-11.3 >> // >> >> On Mon, Jul 6, 2020 at 2:52 PM Brain Rebooting <siumastroma...@gmail.com> >> wrote: >> >>> OK. Here I am going to submit my simple source code of JavaFX program, >>> that should show a black and white chessboard. >>> >>> >>> ------------------------------------------------------------------------------------------------------------------------------------------------ >>> >>> >>> import javafx.application.Application; >>> import javafx.scene.Scene; >>> import javafx.scene.layout.Pane; >>> import javafx.scene.paint.Color; >>> import javafx.stage.Stage; >>> import javafx.scene.shape.Rectangle; >>> >>> /** >>> * >>> * @author samiul alom sium >>> * date: 07.07.2020 >>> * >>> * problem: (Game: display a checkerboard) Write a program that displays >>> * a checkerboard in which each white and black cell is a Rectangle >>> * with a fill color black or white. >>> */ >>> >>> public class DisplayACheckBoard extends Application { >>> >>> @Override >>> public void start(Stage primaryStage) { >>> >>> double WIDTH = 200; >>> double HEIGHT = 200; >>> >>> // create a pane >>> Pane pane = new Pane(); >>> >>> for(int i = 0; i < 8; i++){ >>> boolean isWhite = i % 2 == 0; >>> for(int j = 0; j < 8; j++){ >>> Rectangle rectangle = new Rectangle(i * WIDTH / 8, >>> j * HEIGHT / 8, WIDTH / 8, HEIGHT / 8); >>> >>> rectangle.setStroke(Color.BLACK); >>> >>> if(isWhite){ >>> rectangle.setFill(Color.WHITE); >>> } >>> else { >>> rectangle.setFill(Color.BLACK); >>> } >>> >>> isWhite = !isWhite; >>> >>> pane.getChildren().add(rectangle); >>> >>> // create scene >>> Scene scene = new Scene(pane, WIDTH, HEIGHT); >>> primaryStage.setTitle("Display A CheckBoard"); >>> primaryStage.setScene(scene); >>> primaryStage.show(); >>> >>> } // end of inner for loop >>> } // end of outer for loop >>> >>> } >>> >>> public static void main(String[] args) { >>> launch(args); >>> >>> >>> ------------------------------------------------------------------------------------------------------------------------------------------------------ >>> >>> Here I used: >>> >>> JDK: amazon corretto 1.8.0 252 >>> OS: Ubuntu 18.04.4 LTS >>> IDE: Apache NetBeans 12 >>> Build Tool: Ant >>> >>> // >>> Extra info: >>> Even netbeans-12 error detector didn't show any error on the above code. >>> Problem arises when I am going to run the code. I try to clean and build >>> projects and then run the projects, but still same results come in. But the >>> strange thing is, this same source code works in IntelliJ IDEA community >>> edition with same compiler. Even I can't remember I could see any GUI >>> result of my JavaFX program in NB-12, but I could do that well in NB-11.3 >>> // >>> >>> On Mon, Jul 6, 2020 at 1:08 PM Geertjan Wielenga <geert...@apache.org> >>> wrote: >>> >>>> Can you provide any info so someone can reproduce the problem? >>>> >>>> Gj >>>> >>>> On Mon, 6 Jul 2020 at 08:02, Brain Rebooting <siumastroma...@gmail.com> >>>> wrote: >>>> >>>>> Probably not only this specific program. After installing NetBeans 12, >>>>> none of my JavaFX program show output (with ant build). But NetBeans 11.3 >>>>> with all same configuration, did output my JavaFX program. >>>>> >>>>> On Mon, Jul 6, 2020 at 11:47 AM Brain Rebooting < >>>>> siumastroma...@gmail.com> wrote: >>>>> >>>>>> >>>>>> Problems started from this line on the console: >>>>>> >>>>>> Exception in Application start method >>>>>> >>>>>> But when I run the same program in IntelliJ IDEA community edition, >>>>>> it just works and literally I don't see any error on my own source code. >>>>>> Apache NetBeans error detector don't show any error on my source code. >>>>>> But >>>>>> still when I try to execute it, these errors are displaying on the >>>>>> console. >>>>>> >>>>>> On Mon, Jul 6, 2020 at 11:43 AM Emilian Bold <emilian.b...@gmail.com> >>>>>> wrote: >>>>>> >>>>>>> Please send email to the mailing list (reply all) not just to me. >>>>>>> >>>>>>> --emi >>>>>>> >>>>>>> lun., 6 iul. 2020, 08:34 Brain Rebooting <siumastroma...@gmail.com> >>>>>>> a scris: >>>>>>> >>>>>>>> Problems started from this line on the console: >>>>>>>> >>>>>>>> Exception in Application start method >>>>>>>> >>>>>>>> But when I run the same program in IntelliJ IDEA community edition, >>>>>>>> it just works and literally I don't see any error on my own source >>>>>>>> code. >>>>>>>> Apache NetBeans error detector don't show any error on my source code. >>>>>>>> But >>>>>>>> still when I try to execute it, these errors are displaying on the >>>>>>>> console. >>>>>>>> >>>>>>>> On Mon, Jul 6, 2020 at 11:30 AM Emilian Bold < >>>>>>>> emilian.b...@gmail.com> wrote: >>>>>>>> >>>>>>>>> Start by telling us which errors you see. >>>>>>>>> >>>>>>>>> --emi >>>>>>>>> >>>>>>>>> lun., 6 iul. 2020, 08:04 Brain Rebooting <siumastroma...@gmail.com> >>>>>>>>> a scris: >>>>>>>>> >>>>>>>>>> Why Apache NetBeans 12 don't execute my JavaFX program? I run the >>>>>>>>>> same to same program in IntelliJ IDEA community edition and it >>>>>>>>>> works. But >>>>>>>>>> NetBeans shows there are some errors. Here is my software usage: >>>>>>>>>> >>>>>>>>>> Apache NetBeans 12 >>>>>>>>>> Ubuntu 18 >>>>>>>>>> JDK 8 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Samiul alom sium >>>>>>>>>> Bangladesh >>>>>>>>>> >>>>>>>>>