-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
90 lines (80 loc) · 3.43 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package rsa2;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Main implements ActionListener {
static JButton instructorButton;
static JButton studentButton;
static JFrame home;
static JFrame instructorWindow;
static JFrame studentWindow;
public static void main(String[] args) {
home = new JFrame();
home.getContentPane().setLayout(null);
home.setSize(1050, 643);
ImageIcon ii1 = new ImageIcon();
JLabel l1 = new JLabel();
l1.setSize(1050, 620);
ii1 = new ImageIcon("src/rsa2/uni.png");
Image img = ii1.getImage();
Image imgg = img.getScaledInstance(l1.getWidth(), l1.getHeight(), Image.SCALE_SMOOTH);
ImageIcon scalemenu = new ImageIcon(imgg);
l1.setIcon(scalemenu);
JLabel homeLabel = new JLabel("LOGIN AS");
homeLabel.setBounds(655, 150, 200, 30);
homeLabel.setForeground(new Color(206, 183, 111, 255));
homeLabel.setFont(new Font("Calibri", Font.BOLD, 30));
studentButton = new JButton("Student");
studentButton.setBounds(620, 240, 200, 60);
studentButton.setFont(new Font("", Font.BOLD, 24));
studentButton.setBackground(new Color(206, 183, 111, 255));
studentButton.addActionListener(new Main());
instructorButton = new JButton("Instructor");
instructorButton.setBounds(620, 320, 200, 60);
instructorButton.setFont(new Font("", Font.BOLD, 24));
instructorButton.setBackground(new Color(206, 183, 111, 255));
instructorButton.addActionListener(new Main());
home.add(homeLabel);
home.add(studentButton);
home.add(instructorButton);
home.add(l1);
home.setVisible(true);
home.setLocation(250, 250);
home.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
home.setLocationRelativeTo(null); // Center the window
home.setResizable(false);
}
@Override
public void actionPerformed(ActionEvent e) {
JLabel l2 = new JLabel();
l2.setBounds(20, 0, 60, 60);
ImageIcon ii2 = new ImageIcon("src/rsa2/uni.png");
Image img = ii2.getImage();
Image logo = img.getScaledInstance(l2.getWidth(), l2.getHeight(), Image.SCALE_SMOOTH);
ImageIcon scalemenu = new ImageIcon(logo);
l2.setIcon(scalemenu);
if (e.getSource() == instructorButton) {
home.setVisible(false); // hide the first page
home.dispose();
instructorWindow = new JFrame();
instructorWindow.setSize(1000, 650);
instructorWindow.setLocationRelativeTo(null);
instructorWindow.setTitle("Instructor Portal");
instructorWindow.getContentPane().setLayout(null);
// to call Login class
Login login = new Login();
}
if (e.getSource() == studentButton) {
home.setVisible(false); // hide the first page
home.dispose();
// Create the new JFrame for the student portal
studentWindow = new JFrame();
studentWindow.setSize(1000, 650);
studentWindow.setLocationRelativeTo(null);
studentWindow.setTitle("Student Portal");
studentWindow.getContentPane().setLayout(null);
// to call Login class
Login login = new Login();
}
}
}