Notes
Notes - notes.io |
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.BorderLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.ButtonGroup;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Scanner;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import java.awt.Color;
public class Login extends JFrame {
private JFrame LF;
private JTextField utn;
private JPasswordField upass;
private final ButtonGroup btnr = new ButtonGroup();
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Login rj = new Login();
rj.LF.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Login() {
initialize();
}
private void initialize() {
LF = new JFrame();
LF.setResizable(false);
LF.setTitle("Northampton human resource management");
LF.setBounds(400, 100, 620, 437);//bounds has been given
LF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
LF.getContentPane().setLayout(null);
JLabel top = new JLabel("welcome to HRD login");//top messege has been provided
top.setForeground(Color.blue);//colour has provided
top.setHorizontalAlignment(SwingConstants.CENTER);
top.setFont(new Font("Bernard MT Condensed", Font.BOLD, 25));//font size and design has been provided
top.setBounds(12, 10, 579, 69);//bounds has been given
LF.getContentPane().add(top);
JLabel unrj = new JLabel("Enter Username");//input required
unrj.setForeground(Color.WHITE);
unrj.setFont(new Font("Times New Roman", Font.BOLD, 25));//font size adn design has been provided
unrj.setBounds(99, 89, 179, 29);
LF.getContentPane().add(unrj);
JLabel unpw = new JLabel("Enter Password");//input required
unpw.setForeground(Color.WHITE);
unpw.setFont(new Font("Times New Roman", Font.BOLD, 25));//font size adn design has been given
unpw.setBounds(99, 139, 169, 29);//bounds has been given
LF.getContentPane().add(unpw);
utn = new JTextField();
utn.setFont(new Font("Times New Roman", Font.PLAIN, 19));//font size and design has been given
utn.setBounds(299, 89, 199, 29);//bounds has been given
LF.getContentPane().add(utn);
utn.setColumns(10);
upass = new JPasswordField();
upass.setFont(new Font("Times New Roman", Font.PLAIN, 19));
upass.setColumns(9);
upass.setBounds(299, 139, 199, 29);
LF.getContentPane().add(upass);
JLabel lgrj = new JLabel("LogIn As");//info provided
lgrj.setForeground(Color.WHITE);
lgrj.setFont(new Font("Times New Roman", Font.BOLD, 25));
lgrj.setBounds(99, 189, 149, 29);
LF.getContentPane().add(lgrj);
JRadioButton ds = new JRadioButton(" secratery");//radiobutton has been created
ds.setBackground(Color.LIGHT_GRAY);
btnr.add(ds);
ds.setActionCommand("seceratary");
ds.setFont(new Font("Times New Roman", Font.BOLD, 19));//font size and design has been given
ds.setBounds(299, 189, 169, 25);//bounds has been given
LF.getContentPane().add(ds);
JRadioButton rnad = new JRadioButton(" administrator");//radiobutton has been created for administrator
rnad.setBackground(Color.LIGHT_GRAY);
btnr.add(rnad);
rnad.setActionCommand("admin");
rnad.setFont(new Font("Times New Roman", Font.BOLD, 19));
rnad.setBounds(299, 229, 169, 25);
LF.getContentPane().add(rnad);
JButton rjlg = new JButton("LogIn");//login has been created
rjlg.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent st) {
if (st.getSource() == rjlg) {
String un = utn.getText();
char[] pwd = upass.getPassword();
String person = btnr.getSelection().getActionCommand();
//System.out.println(staffType);
if (un.equals("") || pwd.equals("") ) {//password has been verified
JOptionPane.showMessageDialog(null, " username and password required");//required
}
else {
tryLogin();
utn.setText(null);
upass.setText(null);
ds.setSelected(false);
rnad.setSelected(false);
btnr.clearSelection();
}
}
}
});
rjlg.setFont(new Font("Times New Roman", Font.BOLD, 20));
rjlg.setBounds(136, 288, 89, 23);
LF.getContentPane().add(rjlg);
JButton rjrs = new JButton("Reset");//reset button has been created
rjrs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
utn.setText(null);
upass.setText(null);
ds.setSelected(false);
rnad.setSelected(false);
btnr.clearSelection();
}
});
rjrs.setFont(new Font("Times New Roman", Font.BOLD, 19));
rjrs.setBounds(249, 291, 90, 25);
LF.getContentPane().add(rjrs);
JButton rjex = new JButton("Exit");//exit button has been created
rjex.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
rjex.setFont(new Font("Times New Roman", Font.BOLD, 19));//dont has been designed
rjex.setBounds(359, 291, 90, 25);//font has been designed
LF.getContentPane().add(rjex);
JLabel rjlbl = new JLabel("");
rjlbl.setHorizontalAlignment(SwingConstants.CENTER);
rjlbl.setIcon(new ImageIcon("C:\Users\User\Pictures\timthumb.png"));
rjlbl.setBounds(0, 0, 513, 307);
LF.getContentPane().add(rjlbl);
}
public void tryLogin() {
String rjun = utn.getText();
char[] ippw = upass.getPassword();
String rjpass = new String(ippw);
String person = btnr.getSelection().getActionCommand();
if (person.equals("seceratary")) {
boolean find = false;
String rjh = "";
String rjg = "";
String file = "files/DepartmentSLoginChecking.txt";//file location has been given
try {
Scanner scan = new Scanner(new File(file));//scanner has been provided to scan files
scan.useDelimiter("[,n]");
while (scan.hasNext() && !find)
{
rjh = scan.next();
rjg = scan.next();
if ((rjh.trim().equals(rjun) && rjg.trim().equals(rjpass))
&& person.equals("seceratary"))
{
find = true;
JOptionPane.showMessageDialog(null, "department seceratory login successful");//dialofue has been created
LF.dispose();
seceratorypanel.main(null);
}
}
if(!find) {
JOptionPane.showMessageDialog(null, "Incorrect department seceratory username or password");
}
scan.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
else if (person.equals("admin"))
{
boolean find = false;
String rjh = "";
String rjg = "";
String file = "files/ReceptionLoginCheck.txt";
try {
Scanner scan = new Scanner(new File(file));
scan.useDelimiter("[,n]");
while (scan.hasNext() && !find) {
rjh = scan.next().trim();
rjg = scan.next().trim();
if ((rjh.equals(rjun) && rjg.equals(rjpass)))
{
find = true;
JOptionPane.showMessageDialog(null, "admin login successful");//dialogue has been provided
LF.dispose();
adminpanel.main(null);
}
}
if(!find) {
JOptionPane.showMessageDialog(null, "Incorrect admin username or password");//admin validation has been done
}
scan.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
else {
JOptionPane.showMessageDialog(null, "please repeat again ");//dialoge has been provided
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team