This project demonstrates a simple JavaFX application with user registration and login functionality, designed using JavaFX and Scene Builder. The frontend is built with FXML and controls like TextField, Button, and more, and the backend handles user interactions like registering and logging in, with Laragon used as the recommended environment for MySQL.
Before you begin, ensure you have the following installed:
- Java Development Kit (JDK) 11 or later: Oracle JDK or OpenJDK
- JavaFX SDK: Download JavaFX SDK
- Scene Builder: Gluon Scene Builder
- Laragon: Laragon Download, which provides an easy-to-use development environment with MySQL.
- IDE:
- Visual Studio Code with the Java Extension Pack
- OR Eclipse IDE
-
Install the JDK:
- Download and install JDK 11 or higher from Oracle JDK or OpenJDK.
-
Install the Java Extension Pack:
- Open VS Code.
- Go to the Extensions tab (
Ctrl + Shift + X
), search for Java Extension Pack, and install it.
-
Configure the JDK Path:
- If the JDK isn't automatically detected, configure it manually:
- Open Settings (
Ctrl + ,
). - Search for
java.configuration.runtimes
and configure the path to your JDK installation like this:"java.configuration.runtimes": [ { "name": "JavaSE-11", "path": "C:/Program Files/Java/jdk-11", "default": true } ]
- Open Settings (
- If the JDK isn't automatically detected, configure it manually:
-
Install JavaFX SDK:
- Download the JavaFX SDK from JavaFX SDK.
- Extract it and set it up in your project.
-
Install Scene Builder:
- Download and install Scene Builder from Gluon Scene Builder.
- In VS Code, you can link FXML files to open with Scene Builder.
-
Install Eclipse:
- Download and install Eclipse IDE for Java Developers from Eclipse Download.
-
Install the JDK:
- Download and install JDK 11 or above from Oracle JDK.
-
Set up JDK in Eclipse:
- Open Eclipse.
- Navigate to Window > Preferences > Java > Installed JREs.
- Add your installed JDK path (e.g.,
C:/Program Files/Java/jdk-11
).
-
Install JavaFX Plugin from Eclipse Marketplace:
- Open Eclipse.
- Go to Help > Eclipse Marketplace.
- Search for e(fx)clipse in the marketplace and install it. This plugin provides tooling support for JavaFX, including FXML support.
- Restart Eclipse after installation.
-
Set up JavaFX SDK:
- Download and install the JavaFX SDK from JavaFX SDK.
- Add the JavaFX
.jar
files in the Build Path:- Right-click on your project > Build Path > Configure Build Path > Add External JARs > Select all
.jar
files in thelib
folder of the JavaFX SDK.
- Right-click on your project > Build Path > Configure Build Path > Add External JARs > Select all
-
Install Scene Builder:
- Download Scene Builder from Scene Builder to design your FXML files visually.
- Set it up in Eclipse to open
.fxml
files automatically.
- Ensure that your JavaFX SDK is properly configured in your project.
- Open the project in VS Code.
- Run your JavaFX application by executing:
java --module-path <path_to_javafx_sdk> --add-modules javafx.controls,javafx.fxml -jar <your_jar_file>.jar
- Open the project in Eclipse.
- Right-click your Main Class (e.g.,
MON.java
) and select Run As > Java Application.
This project uses Laragon as the recommended development environment for MySQL. Follow these steps to set it up:
-
Download and Install Laragon:
- Download Laragon from the official website.
- Install it and start the environment.
-
Create MySQL Database:
- Launch MySQL via Laragon. You can manage databases using phpMyAdmin.
- Create a new database for your project:
CREATE DATABASE account; USE account; CREATE TABLE user ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL );
-
Database Connection in Code:
- In your JavaFX project, ensure that the database connection class (
MON_database.java
) connects to MySQL usingJDBC
. Example connection code:public class MON_database { public static Connection connectDB() { try { String url = "jdbc:mysql://localhost:3306/account"; String user = "root"; String password = ""; Connection connection = DriverManager.getConnection(url, user, password); return connection; } catch (SQLException e) { e.printStackTrace(); return null; } } }
- In your JavaFX project, ensure that the database connection class (
-
MySQL Workbench (Optional):
- If you prefer, you can use MySQL Workbench to manage your database, but Laragon’s built-in phpMyAdmin is more lightweight for quick testing.
If you'd like to contribute to this project, feel free to submit a pull request or open an issue.
This project is licensed under the MIT License - see the LICENSE file for details.