Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. /**
  2. * Student Attendance System
  3. * Object Oriented Programming
  4. * P03
  5. * Nicholas Leong
  6. * 1002827B
  7. */
  8.  
  9. //Import required GUI files
  10. import java.util.*;
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. import javax.swing.*;
  14. import java.util.Vector;
  15.  
  16. public class AttendanceGUI {
  17.  
  18. JTextField usernameEntry, passwordEntry;
  19. JLabel username, password;
  20. JButton bLogin,bClear;
  21. JPanel pTop;
  22. JFrame mainFrame;
  23.  
  24. public AttendanceGUI() {
  25.  
  26. mainFrame = new JFrame();
  27. mainFrame.setTitle("Student Attendance System");
  28. mainFrame.setSize(400,150);
  29. mainFrame.setLocation(100,100);
  30. mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  31.  
  32. pTop = new JPanel();
  33. pTop.setLayout(new GridLayout(3,2));
  34.  
  35. usernameEntry = new JTextField("Student ID");
  36. passwordEntry = new JTextField("Matric Number");
  37. username = new JLabel("Username",JLabel.LEFT);
  38. password = new JLabel("Password",JLabel.LEFT);
  39.  
  40. bLogin = new JButton("Login");
  41. bLogin.addActionListener(new ButtonHandler());
  42.  
  43. bClear = new JButton("Clear");
  44. bClear.addActionListener(new ButtonHandler());
  45.  
  46. pTop.add(username);
  47. pTop.add(usernameEntry);
  48. pTop.add(password);
  49. pTop.add(passwordEntry);
  50. pTop.add(bLogin);
  51. pTop.add(bClear);
  52.  
  53. mainFrame.add(pTop);
  54. mainFrame.setVisible(true);
  55. }
  56.  
  57. public static void main(String [] args)
  58. {
  59. JFrame.setDefaultLookAndFeelDecorated(true);
  60. AttendanceGUI attendanceSystem = new AttendanceGUI();
  61. }
  62.  
  63. public class ButtonHandler implements ActionListener{
  64. public void actionPerformed(ActionEvent evt)
  65. {
  66. if(evt.getSource() == bLogin)
  67. {
  68. String studentID = usernameEntry.getText();
  69. String studentPassword = passwordEntry.getText();
  70. String adminAccount="admin";
  71. String adminPassword="pass";
  72. Date today = new Date();
  73. JOptionPane.showMessageDialog(mainFrame, "Student ID: "+studentID+" Login Date: "+today.toString() , "Attendance Marked", JOptionPane.INFORMATION_MESSAGE);
  74. }
  75. if(evt.getSource() == bClear)
  76. {
  77. usernameEntry.setText("");
  78. passwordEntry.setText(""); String
  79. }
  80. }
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement