Skip to content

Weather_App is a modern Java desktop application that delivers real-time weather information for any city worldwide. With a clean and intuitive GUI, users can easily search for a city and instantly view its current weather, including temperature, humidity, wind speed, and weather conditions-all powered by live data from a public weather API.

Notifications You must be signed in to change notification settings

user23052036/Weather_App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌦️ Weather_App

Weather_App is a modern Java desktop application that delivers real-time weather information for any city worldwide. With a clean and intuitive GUI, users can easily search for a city and instantly view its current weather, including temperature, humidity, wind speed, and weather conditions-all powered by live data from a public weather API.

🚀 Features

  • Instant weather search by city name
  • Displays temperature, humidity, and wind speed
  • Shows weather conditions with descriptive text and icons (clear, cloudy, rain, snow)
  • Real-time data retrieval from a trusted weather API
  • Elegant and responsive Java Swing-based GUI
  • Clickable search button with custom icon
  • Automatic weather icon updates based on conditions

🛠️ Technical Overview

  • Frontend: Built entirely with Java Swing, providing a robust, platform-independent graphical interface. The GUI features custom icons, styled text, and intuitive layout for a seamless user experience.
  • Backend: Powered by two main Java packages:
    • java.net.http: Handles all HTTP requests and responses, enabling the app to fetch up-to-date weather data from the API efficiently and reliably.
    • org.json: Parses and processes JSON responses from the API, extracting relevant weather details for display in the GUI.

📁 Project Structure

  • AppLauncher.java
    • Purpose: Entry point of the application. Ensures the GUI is launched safely on the Event Dispatch Thread for thread-safe Swing operations.
    • main(String[] args): Uses SwingUtilities.invokeLater to create and display the weatherGUI window.
  • weatherGUI.java
    • Purpose: Implements the main graphical user interface and handles all user interactions.
    • weatherGUI(): Constructor that sets up the window, initializes components, and arranges them with absolute positioning.
    • addComponents(): Adds and configures all GUI elements-search bar, button, weather icon, temperature, description, humidity, and windspeed labels.
    • actionPerformed(ActionEvent e): Handles the search button click: fetches weather data for the entered city, updates all display fields and icons accordingly.
    • LoadImage(String path): Utility to load image assets (icons) from file paths, used for weather condition icons, search button, humidity, and windspeed images.
  • WeatherAPI.java
    • Purpose: Handles all backend operations: fetching weather data from the API, parsing JSON, and mapping weather codes to descriptive categories.
    • WeatherData(String location): Sends an HTTP request to the weather API for the specified city, parses the JSON response, and updates static fields for temperature, wind speed, humidity, and weather description.
    • WeatherCondition(int weatherCode): Maps the weather code from the API to one of four categories: clear, cloudy, rain, or snow, using predefined sets of codes.
    • Static Fields: temperature, wind_speed, humidity, and weather_descriptions are updated after each API call for use in the GUI.
    • API Integration: Uses java.net.http.HttpClient for HTTP requests and org.json for JSON parsing.
  • assets/
    • Contains PNG image resources for weather icons (e.g., clear, cloudy, rain, snow), search button, humidity, and windspeed.

🔮 Future Enhancements

Future releases will introduce a more advanced frontend using JavaFX for richer interactivity, animations, and enhanced visual appeal. Planned improvements include animated weather icons, theme customization, and extended forecast support.

📦 How to Use

  1. Clone or download this repository.
  2. Ensure you have Java 11 or later installed.
  3. Build the project using your preferred IDE or javac.
  4. Run AppLauncher.java to start the application.
  5. Enter a city name in the search bar and click the search icon to view the latest weather.

⚙️ Requirements

  • Java 11 or later
  • Internet connection (for live weather data)

🙌 Credits

Developed by user23052036
Weather data powered by WeatherStack

About

Weather_App is a modern Java desktop application that delivers real-time weather information for any city worldwide. With a clean and intuitive GUI, users can easily search for a city and instantly view its current weather, including temperature, humidity, wind speed, and weather conditions-all powered by live data from a public weather API.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages