Skip to content

Cross‑platform Java Swing quiz app with a polished FlatLaf UI and MySQL data store for users and questions.

Notifications You must be signed in to change notification settings

MrSrc768/QuizDual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuizDual

A Java Swing quiz application with topic selection, difficulty levels, login, countdown timer, scoring, and a modern FlatLaf UI. Data (users, questions) is stored in MySQL.

Demo

Features

  • User login (validates against Users table)
  • Difficulty levels: Easy, Moderate, Hard
  • Select multiple topics per difficulty
  • 15-second timer per question, instant feedback, and scoring
  • Clean look-and-feel using FlatLaf

Project structure

  • src/QuizApplication.java — main Swing application entry point
  • src/Quiz_DB.sql — MySQL schema and seed data (run this first)
  • resources/ — app resources (e.g., fonts like PlayfairDisplay-Regular.ttf)
  • ScreenRecording/QuizDual-Application-Demo-video.mp4 — demo video

Prerequisites

  • Java JDK 11 or newer
  • MySQL Server 8+
  • JDBC driver: mysql-connector-j-9.1.0.jar
  • FlatLaf for Swing (e.g., flatlaf-<version>.jar)
  • IDE: IntelliJ IDEA (Ultimate recommended for built-in Database tools; Community works fine as well)

IntelliJ IDEA Ultimate can connect to MySQL directly. That helps browse data and run the SQL script, but the app still connects via JDBC at runtime — ensure the JDBC jars are on the classpath and the credentials in code are set.

1) Set up the database

  1. Create a database (example name: quizdual).
  2. Open/Run src/Quiz_DB.sql against your MySQL instance to create tables and seed data.
    • In IntelliJ Ultimate: View > Tool Windows > Database > add MySQL data source > run the script.
    • Or use any MySQL client and execute the file contents.
  3. Ensure the Users table has at least one username/password you can log in with.

2) Configure database credentials (required)

Edit src/QuizApplication.java to match your MySQL configuration:

private static final String DB_URL = "jdbc:mysql://localhost:3306/<your_database_name>";
private static final String DB_USER = "<your_mysql_user>";
private static final String DB_PASSWORD = "<your_mysql_password>";
  • Replace placeholders with your actual DB, user, and password.
  • If needed, append parameters such as ?useSSL=false&serverTimezone=UTC.

Reminder: You must change Database_URL, Database_USER, Database_Password to your MySQL configuration before running the app.

3) Add libraries to your project

You need to include these jars on the classpath:

  • mysql-connector-j-9.1.0.jar
  • flatlaf-<version>.jar

Option A — IntelliJ (recommended)

  1. Open the project in IntelliJ.
  2. File > Project Structure > Modules > Dependencies > + > JARs or directories…
  3. Add the two jars above (download them and place anywhere in/near the project, e.g., lib/).
  4. Apply and OK.
  5. Create a Run Configuration:
    • Main class: QuizApplication
    • Working directory: project root
    • Use classpath of module where you added the jars.
  6. Run.

Option B — Command line (Windows PowerShell)

  1. Create a lib folder at the project root and place the jars:
    • lib/mysql-connector-j-9.1.0.jar
    • lib/flatlaf-<version>.jar
  2. Compile:
# Create output dir
mkdir -Force out | Out-Null

# Compile sources (adjust FlatLaf version)
javac -cp "lib/flatlaf-<version>.jar;lib/mysql-connector-j-9.1.0.jar;src" -d out src\QuizApplication.java
  1. Run:
java -cp "out;lib/flatlaf-<version>.jar;lib/mysql-connector-j-9.1.0.jar" QuizApplication

If you load fonts or other resources, ensure their paths are accessible at runtime.

How to use

  1. Start the application.
  2. Log in with a username/password present in the Users table.
  3. Review rules, pick a difficulty, select desired topics, and start the quiz.
  4. Answer questions within the time limit; view feedback and final stats at the end.

Troubleshooting

  • Database connection error: verify DB_URL, DB_USER, DB_PASSWORD, DB name, and that MySQL is running. Try connecting with the same creds via IntelliJ Database tools.
  • ClassNotFoundException (JDBC or FlatLaf): make sure both jar files are on the runtime classpath (IDE or CLI).
  • Login fails: confirm the Users table contains the credentials you try; ensure the SQL script executed successfully.
  • Timezone/SSL warnings: add connection params to the JDBC URL (e.g., ?useSSL=false&serverTimezone=UTC).

Notes

  • FlatLaf can be switched to other themes; see FlatLaf docs for Dark variants.
  • Avoid committing real DB credentials. Prefer environment variables or a config file for production-like use.

About

Cross‑platform Java Swing quiz app with a polished FlatLaf UI and MySQL data store for users and questions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages