Coders Packet

Connect Four Game Packet using JavaFX

By Satyam Singh

It is a game where players have to connect four of their balls. The one who connects first will be the winner. JavaFX is used for the GUI presentation.

Java's unique GUI library was the Abstract Window Toolkit (AWT). Swing (Chapters 12 and 22) was added to the stage in Java SE 1.2. From that point forward, Swing has stayed the essential Java GUI innovation. Swing is presently in support mode—Oracle has halted improvement and will give just bug fixes going ahead; however, it will remain part of Java is still broadly used.Java's GUI, graphics, and multimedia API of things to come are JavaFX. Sun Microsystems (procured by Oracle in 2010) launched JavaFX in 2007 as a contender to Adobe Flash and Microsoft Silverlight. JavaFX 1.0 was delivered in 2008. Preceding adaptation 2.0, designers utilized JavaFX Script—which was like JavaScript—to compose JavaFX applications. The JavaFX Script source code accumulated to Java bytecode, permitting JavaFX applications to run on the Java Virtual Machine. Beginning with form 2.0 in 2011, JavaFX was reimplemented as a bunch of Java libraries that could be utilized straightforwardly in Java applications.

Here, in this packet, we made a Connect four game using JavaFX.

GUI Presentation:

Gui Representation

Initially, GUI was designed in the connect4.fxml file of JavaFX, in which all the components visible to the users are well placed according to their function. Then in the Main.class file, a start method was introduced which displays the top index of the window which contains menu options, also contains a link between the FXML file and the Main.class file. Then in the Controller.java file every button, text field, etc. is assigned their function code that'll be performed whenever it'll be used. After someone wins, it popups an alert message displaying the winner's name and an option to play more or exit the game.

 

Results:

Winner1

2Winner

It uses all the concepts of JavaFX and a very good project to learn and also a good game to play.

Download project

Reviews Report

Submitted by Satyam Singh (satyams671)

Download packets of source code on Coders Packet