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

Build a login GUI (javafx) form(stage) that asks the user to enter their ID and

ID: 3773851 • Letter: B

Question

Build a login GUI (javafx) form(stage) that asks the user to enter their ID and their password. If the user enters an “A900”, the first char tells us this is a Patient login so use the Patient Business Object to look up the Patient password. If the user enters “D203”, the ‘D’ tells us this is a Dentist trying to login, use the Dentist class to check the password.

If the Patient login is correct:

Navigate to a Patient Form. The patient form should have textboxes to display all the data for a Patient of our Dentist office.

There should also be a button(that says: “Display Appointment”) on the Form to either display the Patient’s appointment in a TextArea    OR    Open a new Form that will display the data for that Patient’s appointment.(javafx)

Explanation / Answer

Program:

package com.java.myapp;
import java.awt.EventQueue;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.sqwing.Jlabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import java.awt.Font;
public class MyForm extends JFrame {
public static String userName;
public static String passWord;
static JLabel lblWelcome;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
MyForm form = new MyForm();
form.setVisible(true);
}
});
}
public MyForm() {
// Create Form Frame
super("login form");
setSize(679, 385);
setLocation(500, 280);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
// Label Welcome
lblwelcome = new JLabel("lblWelcome",JLabel.CENTER);
lblWelcome.setFont(new Font("login", Font.PLAIN, 20));
lblWelcome.setBounds(168, 153, 336, 25);
getContentPane().add(lblWelcome);
// When Frame Loaded
addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
LoginDialog();
}
});
}
public static Boolean getLogin() {
Connection connect = null;
PreparedStatement pre = null;
Boolean status = false;
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection("jdbc:mysql://localhost/mydatabase" +
"?user=root&password=root");   
String sql = " SELECT * FROM member " +
" WHERE Username = ? " +
" AND Password = ? ";
pre = connect.prepareStatement(sql);
pre.setString(1, userName);
pre.setString(2, passWord);
ResultSet rec = pre.executeQuery();
if(rec.next()) {
lblWelcome.setText("Welcome : " + rec.getString("Name"));
status = true;
} else {
JOptionPane.showMessageDialog(null, "Incorrect Username/Password");
}
} catch (Exception e) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null, e.getMessage());
e.printStackTrace();
}
try {
if(pre != null) {
pre.close();
connect.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
e.printStackTrace();
}
return status;
}
public static void LoginDialog() {
JLabel title = new JLabel("Login Username and Password");
JTextField username = new JTextField();
JPasswordField password = new JPasswordField();
final JComponent[] inputs = new JComponent[] {
title,
new JLabel("Username"),
username,
new JLabel("Password"),
password
};
JOptionPane.showMessageDialog(null, inputs, "Login", JOptionPane.PLAIN_MESSAGE);
userName = username.getText();
passWord = new String(password.getPassword());
// Check Login
if(!getLogin())
{
LoginDialog();
}

// display appointment

if(!get appoinment())

{

appointment dialog();

}

{

if(login id= "A900")

System.out.prinln(" this is a patient login");

else

if(login id="D203")

System.out.prinln(" this isa dentist login");

}
}
}

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