Question

In: Computer Science

Need this in java .Create a simple login screen in java That lets people sign in...

Need this in java .Create a simple login screen in java That lets people sign in to the emergency room. It needs to ask for name, social,and DOB. Once all the information is received it then display the info back to them if any info is is missing have the program prompt the user to re enter their information.

Solutions

Expert Solution

import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;


public class LoginFrame extends JFrame {
  
   Label userLbl,socialLbl,DobLbl;
   JTextField userTxtFld,soFld,DobFld;
  
   JButton btnSubmit,btnCancel;
  
   public LoginFrame() {
       userLbl = new Label("Username");
       socialLbl = new Label("Social");
       DobLbl=new Label("Dob");
      
       userTxtFld = new JTextField(20);
       soFld = new JTextField(20);
       DobFld=new JTextField(20);
      
       btnSubmit = new JButton("Submit");
       btnCancel = new JButton("Cancel");
  
      
      
       this.setLayout(new FlowLayout());
      
       this.add(userLbl);
       this.add(userTxtFld);
       this.add(socialLbl);
       this.add(soFld);
       this.add(DobLbl);
      
       this.add(DobFld);
       this.add(btnSubmit);
       this.add(btnCancel);
      
      
       //event linking code
       btnCancel.addActionListener(new ActionListener() {
          
           @Override
           public void actionPerformed(ActionEvent e) {
              
           }
       });
btnSubmit.addActionListener(new ActionListener() {
  
           @Override
           public void actionPerformed(ActionEvent e) {
              
               if(userTxtFld.getText().equals("") && soFld.getText().equals("") && DobFld.getText().equals(""))
               {
                   JOptionPane.showMessageDialog(null, "Please fill the blank fields","Error",JOptionPane.ERROR_MESSAGE);
               }
               else
               {
                   new LoggedInDemo(userTxtFld.getText());
               }
           }
       });
  
   }
  
  
   public static void main(String[] args) {
       JFrame login = new LoginFrame();
       login.setTitle("Login");
       login.setSize(350, 250);
       login.setLocation(100, 200);
       login.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       login.setVisible(true);
   }


   /*@Override
   public void actionPerformed(ActionEvent e) {
       // TODO Auto-generated method stub
      
   }*/
}

//To display the Info

LoggediinDemo.java

import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;

import sun.applet.Main;

public class LoggedInDemo extends JFrame{

   String user;
   public LoggedInDemo(String user) {
       // TODO Auto-generated constructor stub
       this.user=user;
       this.setLayout(new FlowLayout());
       JLabel l1=new JLabel();
       l1.setName(user);
       this.add(l1);
       this.setVisible(true);
       this.setTitle("Login");
       this.setSize(350, 250);
       this.setLocation(100, 200);
   }
  
  
  
}


Related Solutions

very urgent !!! need it asap::::::::Write Java code which will create a GUI window on screen....
very urgent !!! need it asap::::::::Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax
Create a program using python that provides a simple calculator: Requires a login with a prompt...
Create a program using python that provides a simple calculator: Requires a login with a prompt for a username and a password prior to using the calculator If username and password are incorrect, the program should re-prompt to re-enter correct username and password Once logged in, the user should have access to the calculator and should have the ability for the following mathematical operators: Addition Subtraction Multiplication Division Square Root PI Exponents
using PDO, MYSQL, and Html, how can i create a simple registration and login form for...
using PDO, MYSQL, and Html, how can i create a simple registration and login form for cPanel?
Create a program using Java. Create two different 3D arrays with random numbers. (lets name them...
Create a program using Java. Create two different 3D arrays with random numbers. (lets name them array1 and array 2) Add the two 3Darrays together and then get the average. Save the average on a separate 3D array.(lets name it array3) Then add array1 and array3 then get the average Save the average on a separate 3Darray(lets name it array 4) Then add array2 and array3 then get the average Save the average on a separate 3Darray (lets name it...
I need assistance in making a simple html and php script that lets a user explor...
I need assistance in making a simple html and php script that lets a user explor the RGB color specturum. It should be able to use 6 buttons (R+,G+,B+,R-,G-,B-) that when pressed, add or subtract 2 points (ranging from 0-255) of that color from the RGB ratio. The new RGB color is then displayed in a small window/box at the bottom of the page for the user to see. This should allow the user to explore all the different colors...
in java we need to order a list , if we create a program in java...
in java we need to order a list , if we create a program in java what  are the possible ways of telling your program how to move the numbers in the list to make it sorted, where each way provides the required result. list the name of sorting with short explanation
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
Write Java code which will create a GUI window on screen. The window has one button:...
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT