| 15 | |
| 16 | |
| 17 | public class Login extends JFrame implements ActionListener{ |
| 18 | JPanel panel; |
| 19 | JButton studentLoginButton, teacherLoginButton, adminLoginButton; |
| 20 | JLabel title; |
| 21 | public Login(){ |
| 22 | super("Login"); |
| 23 | setSize(360,260); |
| 24 | setLocation(550,365); |
| 25 | setLayout(new BorderLayout()); |
| 26 | |
| 27 | ImageIcon icon = new ImageIcon(ClassLoader.getSystemResource("javasemesterproject/icons/systemIcon.png")); |
| 28 | setIconImage(icon.getImage()); |
| 29 | |
| 30 | panel = new JPanel(); |
| 31 | panel.setLayout(null); |
| 32 | |
| 33 | title = new JLabel("Login Here", JLabel.CENTER); |
| 34 | title.setFont(title.getFont().deriveFont (22.0f)); |
| 35 | title.setBackground(Color.LIGHT_GRAY); |
| 36 | title.setForeground(Color.BLACK); |
| 37 | title.setOpaque(true); |
| 38 | |
| 39 | studentLoginButton = new JButton("Student Login"); |
| 40 | studentLoginButton.addActionListener((ActionListener) this); |
| 41 | studentLoginButton.setHorizontalAlignment(JButton.CENTER); |
| 42 | studentLoginButton.setBounds(115, 15, 120, 40); |
| 43 | |
| 44 | teacherLoginButton = new JButton("Teacher Login"); |
| 45 | teacherLoginButton.addActionListener((ActionListener) this); |
| 46 | teacherLoginButton.setHorizontalAlignment(JButton.CENTER); |
| 47 | teacherLoginButton.setBounds(115, 75, 120, 40); |
| 48 | |
| 49 | adminLoginButton = new JButton("Admin Login"); |
| 50 | adminLoginButton.addActionListener((ActionListener) this); |
| 51 | adminLoginButton.setHorizontalAlignment(JButton.CENTER); |
| 52 | adminLoginButton.setBounds(115, 135, 120, 40); |
| 53 | |
| 54 | // add to panel |
| 55 | panel.add(studentLoginButton); |
| 56 | panel.add(teacherLoginButton); |
| 57 | panel.add(adminLoginButton); |
| 58 | |
| 59 | // Add to Frame |
| 60 | add(title, BorderLayout.NORTH); |
| 61 | add(panel, BorderLayout.CENTER); |
| 62 | |
| 63 | setResizable(false); |
| 64 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
| 65 | setVisible(true); |
| 66 | } |
| 67 | @Override |
| 68 | public void actionPerformed(ActionEvent ae){ |
| 69 | if(ae.getSource() == studentLoginButton){ |
| 70 | setVisible(false); |
| 71 | new StudentLogin(); |
| 72 | } |
| 73 | else if(ae.getSource() == teacherLoginButton){ |
| 74 | setVisible(false); |
nothing calls this directly
no outgoing calls
no test coverage detected