Skip to content
SHUBHAM KARANDE edited this page Jun 4, 2025 · 1 revision

Here’s a Wiki page structure for your Java Temperature Converter project:


Temperature Converter UI (Java)

Overview

The Temperature Converter UI is a Java-based application built using Swing, designed to convert temperatures between Celsius, Kelvin, and Fahrenheit with an intuitive graphical user interface.

Features

  • User-Friendly Interface: Interactive UI with buttons, dropdowns, and labels.
  • Multi-Unit Support: Converts between Celsius, Kelvin, and Fahrenheit.
  • Event Handling: Supports both button clicks and keyboard input.
  • Error Handling: Validates input and provides feedback.
  • Formatted Output: Displays results using DecimalFormat for accuracy.
  • System Look & Feel: Adapts to OS theme using UIManager.

Usage Instructions

  1. Enter the temperature value.
  2. Select the source unit from the dropdown.
  3. Click "Convert" or press Enter to view results.
  4. Click "Clear" to reset inputs.

Installation & Execution

  1. Install Java (JDK).
  2. Clone or download the repository.
  3. Compile and run the application:
    javac TemperatureConverterUI.java
    java TemperatureConverterUI

Code Explanation

Main Components

  • JFrame: Creates the main application window.
  • JPanel: Organizes UI elements.
  • JLabel & JTextField: Handles input and displays results.
  • JComboBox: Allows unit selection.
  • JButton: Triggers conversion and reset actions.
  • ActionListener & KeyListener: Manages user interactions.

Conversion Logic

The conversion method (convertTemperature()) follows:

  • Celsius → Kelvin, Fahrenheit
  • Kelvin → Celsius, Fahrenheit
  • Fahrenheit → Celsius, Kelvin

Error Handling

The application prevents invalid entries by:

  • Catching NumberFormatException if input isn’t numeric.
  • Displaying an alert (JOptionPane) for user feedback.

Potential Enhancements

  • Add real-time conversion without button clicks.
  • Include more units like Rankine and Réaumur.
  • Implement themed UI design for better aesthetics.

License

This project is open-source—feel free to contribute and modify!