Question: import javax.swing. * ; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class RegistrationForm { private JFrame frame; private JTextField firstNameField, lastNameField; public RegistrationForm ( ) { frame
import javax.swing.;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class RegistrationForm
private JFrame frame;
private JTextField firstNameField, lastNameField;
public RegistrationForm
frame new JFrameRegistration Form";
frame.setSize;
frame.setDefaultCloseOperationJFrameEXITONCLOSE;
JPanel panel new JPanel;
panel.setLayoutnew BoxLayoutpanel BoxLayout.YAXIS;
JLabel firstNameLabel new JLabelFirst Name:";
firstNameField new JTextField;
JLabel lastNameLabel new JLabelLast Name:";
lastNameField new JTextField;
JButton submitButton new JButtonSubmit;
submitButton.addActionListenernew ActionListener
@Override
public void actionPerformedActionEvent e
String firstName firstNameField.getText;
String lastName lastNameField.getText;
showConfirmationDialogfirstName lastName;
;
panel.addfirstNameLabel;
panel.addfirstNameField;
panel.addlastNameLabel;
panel.addlastNameField;
panel.addsubmitButton;
frame.addpanel;
frame.setVisibletrue;
private void showConfirmationDialogString firstName, String lastName
JOptionPane.showMessageDialogframe "Registration successful! Welcome, firstName lastName "Confirmation", JOptionPane.INFORMATIONMESSAGE;
public static void mainString args
SwingUtilities.invokeLater new RegistrationForm;
need a screenshots and outputs ss
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
