- Java Create a simple login screen for veterans to sign into the ER. I needs to ask, first name, last name, last 4 of social, and then dob. It then needs to output a screen that displays this info back to then outputs a 5 min wait time under neath all the information that is displayed back to them. Needs to be as simple as possible.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Login extends JFrame implements ActionListener{
/*creating class Login which extends a JFrame and implementing ActionListener interface*/
JButton SUBMIT;
JPanel panel;
JLabel fname,lname,social,dob;
JTextField txtFname,txtLname,txtSocial,txtDob;
/*declaring labels, textfields, panel and button.*/
Login(){
/* calling Login conatructor*/
fname= new JLabel();
fname.setText("First name:");
//setting label nsme to first name
txtFname = new JTextField(20);
//setting textbox fieldsize to 20.
lname = new JLabel();
//creating label lname and fname
lname.setText("Last Name:");
//setting labelname to last name
txtLname = new JTextField(20);
social= new JLabel();
social.setText("Last 4 Social:");
txtSocial = new JTextField(20);
ddob = new JLabel();
dob.setText("DOB:");
txtDob = new JTextField(20);
submit=new JButton("SUBMIT");
panel=new JPanel(new GridLayout(3,1));
panel.add(fname);
panel.add(txtFname);
panel.add(lname);
panel.add(txtLname);
panel.add(social);
panel.add(txtSocial);
panel.add(dob);
panel.add(txtDob);
panel.add(submit);
/*adding labels and textboxes to panel*/
add(panel,BorderLayout.CENTER);
/*adding panel layout to center*/
submit.addActionListener(this);
/*by putting action listener to submit, when clicking this submit button, actionPerformed method will invoked.*/
setTitle("LOGIN FORM");
/* setting form title*/
}
}
public void actionPerformed(ActionEvent ae){
/* When clicking submit button that is the event takesplace, then this method invoked.*/
String fn=txtFname.getText();
String ln=txtLname.getText();
String so=txtSocial.getText();
String db=txtDob.getText();
/* accessing values from above textboxes, and store it in fn ln,so and db string variables*/
JOptionPane.showMessageDialog(this, "Fname is "+fn +" and "+ " Lname is "+ ln+" social is: "+so+" and dob is "+db);
/* isplay a dialoge message fname, lname,social and dob which are accepting by from the textboxes*/
}
}
class LoginDemo // class for msin method
{
public static void main(String arg[])
{
try{
Login frame=new Login();
// creating object for Login and calling Login null constructor
frame.setSize(500,500); //seting frame size
frame.setVisible(true);
//by setting frame visible, it makes visible to the user.
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}
- Java Create a simple login screen for veterans to sign into the ER. I needs...