forked from alexs2112/Scholarship-Thing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewAwards.java
94 lines (74 loc) · 2.89 KB
/
ViewAwards.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
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
public class ViewAwards extends JFrame {
private static final long serialVersionUID = 1060623638149583738L;
private JPanel contentPane;
/**
* Create the frame.
*/
public ViewAwards(Data data, User applicant) {
//design elements
setBounds(100, 100, 743, 445);
contentPane = new JPanel();
contentPane.setBackground(Color.ORANGE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//Get a list of all available awards
ArrayList<Scholarship> awards = data.awards();
//List of all the names of all the scholarships available
String[] names = new String[awards.size()];
for (int i = 0; i < awards.size(); i++) {
names[i] = awards.get(i).getScholName();
}
//drop down menu of scholarships available
JComboBox awardBox = new JComboBox();
awardBox.setBounds(220, 175, 302, 27);
contentPane.add(awardBox);
awardBox.setModel(new DefaultComboBoxModel(names));
//action handler for get info
JButton btnNewButton = new JButton("Get Info");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (awards.size() >= 1) {
//gets the information on the selected scholarship
//displays that information to an option pane with all relevant information about the scholarship
Scholarship award = awards.get(awardBox.getSelectedIndex());
final DecimalFormat df2= new DecimalFormat("#.##");
JOptionPane.showMessageDialog(null, "Award Name: " + award.getScholName() + "\nDonor Name: " + award.getDonorName() + "\nValue: $" + Integer.toString(award.getScholValue()) +
"\nGPA Requirement: " + (df2.format(award.getReq())) + "\nAmount of Awards: " + Integer.toString(award.getTotalAmount()));
}
}
});
btnNewButton.setBounds(246, 253, 117, 29);
contentPane.add(btnNewButton);
//brings user back to the previos page
JButton btnNewButton_1 = new JButton("Back");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
btnNewButton_1.setBounds(379, 253, 117, 29);
contentPane.add(btnNewButton_1);
//design elements
JLabel lblNewLabel = new JLabel("University of Calgary Scholarship Application System");
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 18));
lblNewLabel.setBounds(122, 6, 496, 42);
contentPane.add(lblNewLabel);
}
}