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AgICAgICAgUGVyaW9kIGFnZSA9IFBlcmlvZC5iZXR3ZWVuKGJpcnRoRGF0ZSwgY3VycmVudERhdGUpOwogICAgICAgICAgICAgICAgcmVzdWx0TGFiZWwuc2V0VGV4dCgmcXVvdDtZb3UgYXJlICZxdW90OyArIGFnZS5nZXRZZWFycygpICsgJnF1b3Q7IHllYXJzLCAmcXVvdDsgKyBhZ2UuZ2V0TW9udGhzKCkgKyAmcXVvdDsgbW9udGhzLCBhbmQgJnF1b3Q7ICsgYWdlLmdldERheXMoKSArICZxdW90OyBkYXlzIG9sZC4mcXVvdDspOwogICAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgYWRkKGJpcnRoRGF0ZUxhYmVsKTsKICAgICAgICBhZGQobmV3IEpMYWJlbCgmcXVvdDsmcXVvdDspKTsKICAgICAgICBhZGQobmV3IEpMYWJlbCgmcXVvdDtEYXk6JnF1b3Q7KSk7CiAgICAgICAgYWRkKGRheU9mQmlydGgpOwogICAgICAgIGFkZChuZXcgSkxhYmVsKCZxdW90O01vbnRoOiZxdW90OykpOwogICAgICAgIGFkZChtb250aE9mQmlydGgpZGF5czs=
import java.awt.*;
import java.awt.event.*;
import java.time.*;
import javax.swing.*;
public class AgeCalculator extends JFrame {
private JLabel birthDateLabel, resultLabel;
private JComboBox<Integer> dayOfBirth, monthOfBirth, yearOfBirth;
private JButton calculateButton;
public AgeCalculator() {
setTitle("Age Calculator");
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(5, 2));
birthDateLabel = new JLabel("Enter your birth date:");
resultLabel = new JLabel("Your age will be displayed here.");
Integer[] days = new Integer[31];
for (int i = 1; i <= 31; i++) days[i - 1] = i;
Integer[] months = new Integer[12];
for (int i = 1; i <= 12; i++) months[i - 1] = i;
Integer[] years = new Integer[100];
for (int i = 1920; i <= 2020; i++) years[i - 1920] = i;
dayOfBirth = new JComboBox<>(days);
monthOfBirth = new JComboBox<>(months);
yearOfBirth = new JComboBox<>(years);
calculateButton = new JButton("Calculate Age");
calculateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int day = (int) dayOfBirth.getSelectedItem();
int month = (int) monthOfBirth.getSelectedItem();
int year = (int) yearOfBirth.getSelectedItem();
LocalDate birthDate = LocalDate.of(year, month, day);
LocalDate currentDate = LocalDate.now();
Period age = Period.between(birthDate, currentDate);
resultLabel.setText("You are " + age.getYears() + " years, " + age.getMonths() + " months, and " + age.getDays() + " days old.");
}
});
add(birthDateLabel);
add(new JLabel(""));
add(new JLabel("Day:"));
add(dayOfBirth);
add(new JLabel("Month:"));
add(monthOfBirth)days;