forked from alexs2112/Scholarship-Thing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyAwards.java
129 lines (91 loc) · 3.92 KB
/
MyAwards.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class MyAwards extends JFrame {
private static final long serialVersionUID = 1060623638149583738L;
private JPanel contentPane;
/**
* Create the frame.
*/
public MyAwards(Data data, User applicant) {
//Design Elements
setTitle("University of Calgary Scholarship Application System | My Awards");
setBounds(100, 100, 750, 480);
contentPane = new JPanel();
contentPane.setBackground(Color.ORANGE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//convert User applciant to Applicant applicant
Applicant student = (Applicant)applicant;
//Create an ArrayList scholarships that is a list of all the awards the student has accepted
ArrayList<Scholarship> scholarships = student.acceptedAwards();
//if the arraylist is non empty
if (scholarships.size() >= 1) {
for (Scholarship award : scholarships ) {
//if the award is an annual award, update the appropriate labels
if (award.getAnnual().equals("Annual")) {
JLabel lblNewLabel_4 = new JLabel("Award Name: " + award.getScholName());
lblNewLabel_4.setBounds(38, 107, 200, 16);
contentPane.add(lblNewLabel_4);
JLabel lblNewLabel_5 = new JLabel("Donor Name: " + award.getDonorName());
lblNewLabel_5.setBounds(38, 135, 200, 16);
contentPane.add(lblNewLabel_5);
JLabel lblNewLabel_6 = new JLabel("Award Amount: $" + award.getScholValue());
lblNewLabel_6.setBounds(38, 163, 200, 16);
contentPane.add(lblNewLabel_6);
//if the award is a Fall award, update the appropriate labels
} else if (award.getAnnual().equals("Fall")) {
JLabel lblNewLabel_7 = new JLabel("Award Name: " + award.getScholName());
lblNewLabel_7.setBounds(294, 107, 200, 16);
contentPane.add(lblNewLabel_7);
JLabel lblNewLabel_8 = new JLabel("Donor Name: " + award.getDonorName());
lblNewLabel_8.setBounds(294, 135, 200, 16);
contentPane.add(lblNewLabel_8);
JLabel lblNewLabel_9 = new JLabel("Award Amount: $" + award.getScholValue());
lblNewLabel_9.setBounds(294, 163, 200, 16);
contentPane.add(lblNewLabel_9);
//if the award is a winter award, update the appropriate labels
} else if (award.getAnnual().equals("Winter")) {
JLabel lblNewLabel_10 = new JLabel("Award Name: " + award.getScholName());
lblNewLabel_10.setBounds(525, 107, 200, 16);
contentPane.add(lblNewLabel_10);
JLabel lblNewLabel_11 = new JLabel("Donor Name: " + award.getDonorName());
lblNewLabel_11.setBounds(525, 135, 200, 16);
contentPane.add(lblNewLabel_11);
JLabel lblNewLabel_12 = new JLabel("Award Amount: $" + award.getScholValue());
lblNewLabel_12.setBounds(525, 163, 200, 16);
contentPane.add(lblNewLabel_12);
}
}
}
JLabel lblNewLabel = new JLabel("My Awards");
lblNewLabel.setBounds(294, 18, 78, 16);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("Annual Award");
lblNewLabel_1.setBounds(38, 59, 104, 16);
contentPane.add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("Fall Award");
lblNewLabel_2.setBounds(294, 59, 89, 16);
contentPane.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("Winter Award");
lblNewLabel_3.setBounds(525, 59, 89, 16);
contentPane.add(lblNewLabel_3);
JButton btnNewButton = new JButton("Cancel");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
btnNewButton.setBounds(627, 423, 117, 29);
contentPane.add(btnNewButton);
}
}