Skip to content

Fix Project GUI Visibility and Improve Maintainability - #7

Open
unknownhero88 wants to merge 11 commits into
Adarsh9616:masterfrom
unknownhero88:master
Open

Fix Project GUI Visibility and Improve Maintainability#7
unknownhero88 wants to merge 11 commits into
Adarsh9616:masterfrom
unknownhero88:master

Conversation

@unknownhero88

@unknownhero88 unknownhero88 commented Jun 4, 2026

Copy link
Copy Markdown

Improve Security, Validation, Error Handling, and UI Consistency Across the Electricity Billing System

Summary

This PR introduces multiple improvements across the Electricity Billing System, focusing on security, input validation, database interaction, error handling, resource management, and UI consistency.

Files Updated

  • login.java
  • new_customer.java
  • calculate_bill.java
  • generate_bill.java
  • LastBill.java
  • splash.java

Security Improvements

Replaced SQL String Concatenation with PreparedStatement

Updated database operations to use PreparedStatement instead of dynamic SQL queries.

Affected Modules

  • login.java
  • new_customer.java
  • calculate_bill.java
  • generate_bill.java
  • LastBill.java

Benefits

  • Prevents SQL Injection vulnerabilities.
  • Improves query safety and maintainability.
  • Follows JDBC best practices.

Input Validation Improvements

Customer Creation

Added validation for:

  • Empty fields
  • Invalid user input

Bill Calculation

Added validation for:

  • Empty unit values
  • Non-numeric input
  • Negative unit values

Login

Improved authentication flow and credential handling.


Database Handling Improvements

Bill Generation

  • Added secure customer lookup using PreparedStatement.
  • Fixed bill retrieval logic to use both selected meter number and selected month.

Last Bill

  • Added secure bill history retrieval using PreparedStatement.
  • Prevented duplicate content when reloading bill history.

User Experience Improvements

Login Module

  • Added Cancel button functionality.
  • Improved invalid login behavior.
  • Improved password handling using JPasswordField#getPassword().

Customer Creation

  • Added success and error dialogs.
  • Improved form handling and validation.

Bill Modules

  • Added clear validation messages.
  • Added database failure feedback dialogs.

Last Bill

  • Improved screen labels and button text.
  • Made bill history display read-only.

UI Improvements

Image Rendering

Replaced:

Image.SCALE_DEFAULT

with:

Image.SCALE_SMOOTH

to improve image quality across multiple modules.

Window Management

Added:

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

for child windows and dialogs.

Added:

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

for startup windows.


Splash Screen Improvements

Resource Management

  • Added proper splash screen disposal before launching the login screen.
  • Introduced a named constant (SPLASH_DURATION) for splash duration.
  • Improved thread naming and readability.
  • Added proper interruption handling.

Benefits

  • Better resource cleanup.
  • Improved maintainability.
  • Safer thread management.

Error Handling Improvements

Replaced silent failures and console-only exception handling with user-friendly dialogs using JOptionPane.

Benefits

  • Better user feedback.
  • Easier troubleshooting.
  • Improved application reliability.

Testing Performed

Login

  • Successful login
  • Invalid login
  • Cancel button functionality

Customer Creation

  • Customer creation with valid data
  • Empty field validation
  • Database insertion validation

Bill Calculation

  • Bill generation with valid input
  • Empty input validation
  • Invalid numeric input validation
  • Negative unit validation

Bill Generation

  • Customer lookup
  • Month-specific bill generation
  • Database query validation

Last Bill

  • Bill history retrieval
  • Multiple reload scenarios

Splash Screen

  • Startup animation
  • Transition to login screen
  • Proper resource cleanup

Benefits

  • Improved security
  • Improved user experience
  • Better database handling
  • Cleaner codebase
  • Improved maintainability
  • Better exception handling
  • Consistent UI behavior across modules

Type of Change

  • Security Improvement
  • Bug Fix
  • Code Quality Improvement
  • UI Enhancement
  • Validation Improvement
  • New Feature
  • Breaking Change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant