-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam.java
More file actions
50 lines (49 loc) · 1.25 KB
/
Exam.java
File metadata and controls
50 lines (49 loc) · 1.25 KB
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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Exam extends JFrame implements ActionListener{
JButton test1, test2, test3, test4;
Exam(){
super(" Start the Exam");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane=new JPanel();
test1=new JButton("Maths 1");
test1.addActionListener(this);
test1.setBackground(Color.BLUE);
test2=new JButton("Maths 2");
test2.addActionListener(this);
test2.setBackground(Color.RED);
test3=new JButton("Maths 3");
test3.addActionListener(this);
test3.setBackground(Color.GREEN);
test4=new JButton("Maths 4");
test4.addActionListener(this);
test4.setBackground(Color.YELLOW);
pane.add(test1);
pane.add(test2);
pane.add(test3);
pane.add(test4);
add(pane);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent evt){
Object source=evt.getSource();
if (source == test1){
MathsExam1 mee1=new MathsExam1();
}
else if (source == test2){
MathsExam2 mee2=new MathsExam2();
}
else if (source == test3){
MathsExam3 mee3=new MathsExam3();
}
else if (source == test4){
MathsExam4 mee4=new MathsExam4();
}
repaint();
}
public static void main(String[] args){
Exam e=new Exam();
}
}