Skip to content

Latest commit

 

History

History
108 lines (78 loc) · 5.19 KB

File metadata and controls

108 lines (78 loc) · 5.19 KB

Weather Information App

Project Overview

Goal:
I have Developed a Java-based desktop application that provides real-time weather updates for a user-specified location. The application leverages a weather API (e.g., OpenWeatherMap or Weatherstack) to fetch current weather details and features a user-friendly GUI built with Java Swing.

Core Features

API Integration

  • Uses a weather API to retrieve live data including temperature, humidity, wind speed, and general weather conditions.
  • Requires an API key from the chosen provider and adherence to its usage guidelines.

Graphical User Interface (GUI)

  • Developed using Java Swing.
  • Contains a text field for location input (city name or coordinates).
  • Includes a combo box to select preferred units (Celsius/Fahrenheit and metric/imperial).
  • Features a button to initiate the weather lookup.
  • Displays fetched weather details in a text area or equivalent display panel.

Weather Display & Forecast

  • Shows current weather information in an easy-to-read format.
  • Optionally presents a short-term weather forecast.

Iconography & Visuals

  • Uses icons or images to represent various weather conditions (e.g., a sun icon for clear weather).
  • Implements dynamic backgrounds that change based on the time of day (morning, afternoon, evening).

User Input Validation & Error Handling

  • Validates user inputs to ensure the location is entered correctly.
  • Gracefully handles errors (e.g., network issues, invalid API responses, or wrong location entries) and notifies the user.

Unit Conversion

  • Provides options for users to toggle between temperature units (Celsius and Fahrenheit) and wind speed measurements (metric vs. imperial).

History Tracking

  • Maintains a record of recent weather searches along with timestamps.
  • Allows users to review previous queries.

Code Structure & Key Classes

  • WeatherApp.java

    • Acts as the main entry point.
    • Sets up the GUI layout and handles the primary window and user interactions.
    • Manages event listeners for UI components such as buttons and combo boxes.
  • WeatherAPI.java

    • Handles the integration with the weather API.
    • Makes HTTP requests to fetch real-time weather data and processes JSON/XML responses.
    • Implements error handling for API call failures.
  • WeatherData.java

    • A model class encapsulating weather-related information (temperature, humidity, wind speed, condition, etc.).
    • Provides getters/setters and utility methods for data manipulation.
  • WeatherPanel.java

    • A custom JPanel (or similar component) that organizes the display of weather information.
    • Responsible for updating the UI when new data is fetched.
  • HistoryManager.java

    • Manages the history of weather searches.
    • Stores search terms along with timestamps and may allow re-fetching of previous weather data.

Implementation Details

API Integration

  • Utilize an HTTP client (e.g., HttpURLConnection or third-party libraries like OkHttp) to call the weather API.
  • Parse the JSON response to extract necessary details.

Dynamic GUI Updates

  • Dynamically change backgrounds or UI components based on the current time (e.g., morning background for sunrise).

Unit Conversion

  • Implement logic to convert temperature and wind speed based on the user's unit selection using conversion formulas.

Error Handling

  • Validate user inputs (e.g., check for empty or invalid entries).
  • Check the API response status and display user-friendly error messages for issues like API downtime or network errors.

History Feature

  • Implement a mechanism (e.g., using an in-memory data structure or a file-based solution) to store and retrieve recent searches with timestamps.

How to Get Started

Set Up Your Environment

  • Ensure you have the Java Development Kit (JDK) installed.
  • Acquire an API key from your chosen weather API provider.

Project Setup

  1. Clone the repository from GitHub (or set up a new project in your IDE).
  2. Organize the source files as described (e.g., WeatherApp.java, WeatherAPI.java, etc.).

Development

  • Build the GUI with Java Swing, laying out the input fields, buttons, and display areas.
  • Integrate API call functionality and test fetching real weather data.
  • Add features such as unit conversion, dynamic backgrounds, and history tracking.
  • Implement proper error handling and user notifications.

Testing & Documentation

  • Thoroughly test the application for edge cases (e.g., invalid inputs, API downtime).
  • Write clear comments in your source code.
  • Prepare this README file to explain installation, usage, and any additional notes about your implementation.

Conclusion

The Weather Information App is a comprehensive project that demonstrates proficiency in Java GUI development, API integration, and error handling. The structured approach and clean separation of concerns (using different classes for API calls, data modeling, and UI components) ensure that the application remains maintainable and scalable. This roadmap should help you cover all required features while providing a clear and engaging user experience.

Happy Coding!