Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Student Attendance System
- * Object Oriented Programming
- * P03
- * Nicholas Leong
- * 1002827B
- */
- //Import required GUI files
- import java.util.*;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.util.Vector;
- public class AttendanceGUI {
- JTextField usernameEntry, passwordEntry;
- JLabel username, password;
- JButton bLogin,bClear;
- JPanel pTop;
- JFrame mainFrame;
- public AttendanceGUI() {
- mainFrame = new JFrame();
- mainFrame.setTitle("Student Attendance System");
- mainFrame.setSize(400,150);
- mainFrame.setLocation(100,100);
- mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- pTop = new JPanel();
- pTop.setLayout(new GridLayout(3,2));
- usernameEntry = new JTextField("Student ID");
- passwordEntry = new JTextField("Matric Number");
- username = new JLabel("Username",JLabel.LEFT);
- password = new JLabel("Password",JLabel.LEFT);
- bLogin = new JButton("Login");
- bLogin.addActionListener(new ButtonHandler());
- bClear = new JButton("Clear");
- bClear.addActionListener(new ButtonHandler());
- pTop.add(username);
- pTop.add(usernameEntry);
- pTop.add(password);
- pTop.add(passwordEntry);
- pTop.add(bLogin);
- pTop.add(bClear);
- mainFrame.add(pTop);
- mainFrame.setVisible(true);
- }
- public static void main(String [] args)
- {
- JFrame.setDefaultLookAndFeelDecorated(true);
- AttendanceGUI attendanceSystem = new AttendanceGUI();
- }
- public class ButtonHandler implements ActionListener{
- public void actionPerformed(ActionEvent evt)
- {
- if(evt.getSource() == bLogin)
- {
- String studentID = usernameEntry.getText();
- String studentPassword = passwordEntry.getText();
- String adminAccount="admin";
- String adminPassword="pass";
- Date today = new Date();
- JOptionPane.showMessageDialog(mainFrame, "Student ID: "+studentID+" Login Date: "+today.toString() , "Attendance Marked", JOptionPane.INFORMATION_MESSAGE);
- }
- if(evt.getSource() == bClear)
- {
- usernameEntry.setText("");
- passwordEntry.setText(""); String
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement