Programming Assignment Unit 8
Programming Assignment Unit 8
🔧 Project Overview:
This Weather Information App is developed using JavaFX (without Maven) and
WeatherAPI.com for real-time weather data. The application provides a user-friendly interface
for viewing current weather, short-term forecasts, unit conversion, and maintains a search history
with visual weather icons and dynamic backgrounds.
🔍 Key Features:
Real-time weather data from WeatherAPI.com
GUI built using JavaFX SDK (no external dependencies)
Unit toggle between Celsius and Fahrenheit
Forecast for the next two days
Weather condition icons for better UX
Search history with timestamps
Background changes based on time of day
Robust error handling
🧠 Technical Explanation of Code:
✅ WeatherApp.java (Main Class)
Purpose: Entry point of the app that initializes the GUI and handles the logic for fetching,
parsing, and displaying weather data.
🛠️Key Components Explained:
JavaFX GUI Layout: Utilizes VBox, HBox, GridPane, and Scene for organizing layout.
Event Handling: Uses setOnAction for button click handling.
HTTP Request: WeatherAPI data is fetched using HttpURLConnection.
JSON Parsing: Uses org.json to extract data like temperature, condition, icon, and
forecast.
Unit Toggle Logic: Converts temperature and wind speed between metric and imperial.
History Tracking: Maintains a list of past queries with timestamps.
Dynamic Background: Changes background image depending on system time.
📘 README File (as Notepad Text Format)
==========================
Weather Information App
==========================
Instructions:
-------------
1. Open the project in IntelliJ IDEA.
2. Configure JavaFX SDK in Project Structure.
3. Add VM options:
--module-path "C:\path\to\javafx-sdk\lib" --add-modules
javafx.controls,javafx.fxml
4. Run WeatherApp.java
Usage:
------
- Enter any valid city name (e.g., New York, Riyadh).
- Select temperature unit (Celsius/Fahrenheit).
- Click “Get Weather”.
- View current weather, forecast, icon, and history.
Features:
---------
✔ JavaFX GUI
✔ Real-time Weather
✔ 2-Day Forecast
✔ Temperature Unit Toggle
✔ Weather Icons
✔ Dynamic Background (Day/Night)
✔ Search History
✔ Error Handling
🖼️Screenshots of the App Usage:
Interface: