Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Resubmission - please help me create a java applet in netbeans that ask the user

ID: 3835050 • Letter: R

Question

Resubmission - please help me create a java applet in netbeans that ask the user for their first and last names and their birth year. After the user enters the requested data and clicks the View Greeting button, the form will change the greeting to show a personalized greeting and the user’s current age.

Class imports:

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.util.Calendar;

Form objects:

JLabel greeting

JLabel viewAge

JLabel firstLabel

JTextField txtfirstName

JLabel lastLabel

JTextField txtlastName

JLabel birthLabel

JTextField txtbirthYear

JButton viewGreeting

Form when first opened Applet Viewer: JGreet3 class Applet Greetings! Please enter your first name Please enter your last name: Please enter your four-digit Year of Birth (YYYY) View Greeting Applet started. Form after data entered and View Greeting button clicked Applet Viewer: JGreet .class Applet How are you, John Doe? Your age is 29 years Please enter your first name: John Please enter your last name: Doe Please enter your four-digit Year of Birth (YYYY) 1985 iew Greeting Applet started.

Explanation / Answer

import java.applet.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Sample1 extends Applet implements ActionListener {

JLabel JTextField, viewAgec, firstLabel, lastLabel, birthLabel;
JTextField txtfirstName, txtlastName, txtbirthYear;
JButton viewGreeting;

public void init() {
JTextField = new JLabel("Greetings");
JTextField.setFont(new Font("Serif", Font.PLAIN, 32));
viewAgec = new JLabel("");
firstLabel = new JLabel("Please Enter your first Name");
txtfirstName = new JTextField("");
txtfirstName.setPreferredSize(new Dimension(200, 24));
lastLabel = new JLabel("Please Enter your last Name");
txtlastName = new JTextField("");
txtlastName.setPreferredSize(new Dimension(200, 24));
birthLabel = new JLabel("Please Enter your 4-digit yeay of Birth (YYYY)");
txtbirthYear = new JTextField("");
txtbirthYear.setPreferredSize(new Dimension(200, 24));
viewGreeting = new JButton("View Greeting");
viewGreeting.addActionListener(this);

add(JTextField);
add(viewAgec);
add(firstLabel);
add(txtfirstName);
add(lastLabel);
add(txtlastName);
add(birthLabel);
add(txtbirthYear);
add(viewGreeting);
}

public void actionPerformed(ActionEvent e) {
String firstName = txtfirstName.getText();
String lastName = txtlastName.getText();
int txtbrthyear = Integer.parseInt(txtbirthYear.getText().trim());
JTextField.setText("How are you, " + firstName + " " + lastName);
viewAgec.setText("Your age is " + (Calendar.getInstance().get(Calendar.YEAR) - txtbrthyear) + " years.");
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote