help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
java-math-tools
/
src
/
main
/
java
/
com
/
rskworld
/
mathtools
/
panels
RSK World
java-math-tools
Java Math Tools - 15 Mathematical Tools + Scientific Calculator + Geometry + Statistics + Financial Calculators + Swing GUI + Educational Design
panels
  • AgeCalculatorPanel.java2.4 KB
  • BMIPanel.java2.3 KB
  • CalculatorPanel.java4.5 KB
  • ConstantsPanel.java1.6 KB
  • EquationSolverPanel.java3.3 KB
  • FinancialPanel.java3.2 KB
  • GSTPanel.java2.1 KB
  • GeometryPanel.java4 KB
  • HistoryPanel.java1.8 KB
  • MatrixPanel.java4.2 KB
  • NumberSystemPanel.java3 KB
  • PasswordPanel.java3.2 KB
  • PlotterPanel.java3 KB
  • PrimePanel.java3.5 KB
  • StatisticsPanel.java3.5 KB
  • UnitConverterPanel.java5.8 KB
AgeCalculatorPanel.java
src/main/java/com/rskworld/mathtools/panels/AgeCalculatorPanel.java
Raw Download
Find: Go to:
/**
 * Project: Java Basic Math Tools
 * Developer: Molla Samser
 * Designer & Tester: Rima Khatun
 * Website: https://rskworld.in
 * Year: 2026
 */

package com.rskworld.mathtools.panels;

import com.rskworld.mathtools.utils.ThemeManager;
import javax.swing.*;
import java.awt.*;
import java.time.LocalDate;
import java.time.Period;

public class AgeCalculatorPanel extends JPanel {
    private JComboBox<Integer> day, month, year;
    private JTextArea resultArea;

    public AgeCalculatorPanel() {
        setLayout(new BorderLayout(10, 10));
        setBackground(ThemeManager.BACKGROUND);
        setBorder(BorderFactory.createEmptyBorder(40, 40, 40, 40));
        initComponents();
    }

    private void initComponents() {
        JPanel inputPanel = new JPanel(new FlowLayout());
        inputPanel.setOpaque(false);

        day = new JComboBox<>();
        for(int i=1; i<=31; i++) day.addItem(i);
        
        month = new JComboBox<>();
        for(int i=1; i<=12; i++) month.addItem(i);

        year = new JComboBox<>();
        int currentYear = LocalDate.now().getYear();
        for(int i=currentYear; i>=1900; i--) year.addItem(i);

        inputPanel.add(new JLabel("Day:"));
        inputPanel.add(day);
        inputPanel.add(new JLabel("Month:"));
        inputPanel.add(month);
        inputPanel.add(new JLabel("Year:"));
        inputPanel.add(year);

        JButton calcBtn = new JButton("Calculate Age");
        calcBtn.addActionListener(e -> calculate());
        inputPanel.add(calcBtn);

        add(inputPanel, BorderLayout.NORTH);

        resultArea = new JTextArea();
        resultArea.setEditable(false);
        resultArea.setFont(new Font("SansSerif", Font.BOLD, 18));
        add(new JScrollPane(resultArea), BorderLayout.CENTER);

        ThemeManager.applyTheme(this);
    }

    private void calculate() {
        try {
            LocalDate birthDate = LocalDate.of((Integer)year.getSelectedItem(), (Integer)month.getSelectedItem(), (Integer)day.getSelectedItem());
            LocalDate currentDate = LocalDate.now();
            Period period = Period.between(birthDate, currentDate);

            resultArea.setText(String.format("Age: %d Years, %d Months, %d Days", 
                period.getYears(), period.getMonths(), period.getDays()));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Invalid Date Selected");
        }
    }
}
76 lines•2.4 KB
java

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer