Java Check-In System Tutorial

Here I am building a Check – In system that could be used for patients/ Clients to check in for there appointment. The user will interact with the program by inputting their Name, Last 4 SSN and Phone number.

For this tutorial the library Swing needs to be imported. Swing is used to create Jframes and JLables which we will be using in this project to hold the content of the program. Here are some more tutorials on Swing if you are unfamiliar with the library.

Creating the main frame and giving the program a title

// Create frame & title 
        JFrame frame= new JFrame(); 
        frame.setTitle("JFrame Check-In Demo");
         
               // Main Panel Frame
        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
 
        JPanel headingPanel = new JPanel();
//Heading title
        JLabel headingLabel = new JLabel("Welcome, Please fill out form to Check-In");
        headingPanel.add(headingLabel);
         
// Panel to define the layout
        JPanel panel = new JPanel(new GridBagLayout());
        GridBagConstraints constr = new GridBagConstraints();
        constr.insets = new Insets(5, 5, 5, 5);     
        constr.anchor = GridBagConstraints.WEST;
 
 // Set the initial grid values to 0,0
        constr.gridx=0;
        constr.gridy=0;

This portion of code will set the labels and the Edit text so the users can input their information into the program.

        // Text  
        JLabel LabelOne  = new JLabel("Enter your name :");
        JLabel LabelTwo = new JLabel("Last 4 SSN :");
        JLabel LabelThree = new JLabel("Enter Phone # :");
         
        //  Edit Text  
        JTextField ClientName = new JTextField(20);
        JPasswordField Last = new JPasswordField(20);
        JTextField Phone  = new JTextField(20);
         
        panel.add(LabelOne , constr);
        constr.gridx=1;
        panel.add(ClientName, constr);
        constr.gridx=0; constr.gridy=1;
         
        panel.add(LabelTwo, constr);
        constr.gridx=1;
        panel.add(Last, constr);
        constr.gridx=0; constr.gridy=2;
         
        panel.add(LabelThree, constr);
        constr.gridx=1;
        panel.add(Phone , constr);
        constr.gridy=3;
         
        constr.gridwidth = 2;
        constr.anchor = GridBagConstraints.CENTER;

Here the button is being set and the action listener. When the button is clicked it will prompt a pop up to confirm the Check-In

        // "Check-In Button"
        JButton button = new JButton("Check-In");
        // add ActionListener to button
        button.addActionListener(new ActionListener()
        {
          public void actionPerformed(ActionEvent e)
          {
        	  
        	//Reset edit Text and thank client   
            headingLabel.setText("Thanks for you for Checking-In");
            ClientName.setText("");
            Last.setText("");
            Phone .setText("");
            
            //Pop up Message 
            JOptionPane.showMessageDialog(frame,"Check-In confirmed,we will notify you.");  
            
          }
        });

Last bit of code adds it all to the panel

 // Add label and button to panel
        panel.add(button, constr);
  
        mainPanel.add(headingPanel);
        mainPanel.add(panel);
 
// Add panel to frame
        frame.add(mainPanel);
        frame.pack();
                frame.setSize(400, 400);
                frame.setLocationRelativeTo(null);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}
Output

Android Studio Loading Animation Between Activities

Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the…

Android Studio Tutorial SeekBar

SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value…

Python Ethereum Block Chain Interaction with Web3

This tutorial will show how to interact with the Ethereum blockchain using Python. To start, the Python library Web3 will need to be installed. The Web3 library allows you to interact with a local or remote Ethereum node, using a HTTP or IPC connection. Using Web3 you will be able to create smart contracts on…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s