-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnterScoreGUI.java
126 lines (112 loc) · 2.77 KB
/
EnterScoreGUI.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
package edu.ilstu;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class EnterScoreGUI extends JFrame
{
private static final long serialVersionUID = 1L;
private ScoreButtonPanel sPanel;
private JTextField scoreEntry;
private GradeItem item;
private double score;
/**
* This class will create a pop up screen asking the user to enter either an
* estimated score for an item or an evaluated score on an item.
*
* @param item
*/
public EnterScoreGUI(GradeItem item)
{
super("Score Entry");
this.item = item;
setLayout(new BorderLayout());
setSize(600, 600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
scoreEntry = new JTextField();
score = 0.0;
buildScoreButtonPanel();
add(new JLabel(" "), BorderLayout.NORTH);
add(new JLabel("Score: "), BorderLayout.WEST);
add(scoreEntry, BorderLayout.CENTER);
add(new JLabel(" "), BorderLayout.EAST);
add(sPanel, BorderLayout.SOUTH);
pack();
setVisible(true);
}
public void buildScoreButtonPanel()
{
sPanel = new ScoreButtonPanel();
sPanel.getActualButton().addActionListener(new ActualListener(item));
sPanel.getEstimatedButton().addActionListener(
new EstimatedListener(item));
}
/**
* This class listens for the user to select the actual score button to
* enter an evaluated score for that item.
*
* @author John, Corbin and Rachel
*
*/
private class ActualListener extends Thread implements ActionListener
{
private GradeItem item;
private Course processingCourse;
public ActualListener(GradeItem item)
{
this.item = item;
processingCourse = Course.getInstance();
}
public void actionPerformed(ActionEvent e)
{
dispose();
try
{
score = Double.valueOf(scoreEntry.getText().trim())
.doubleValue();
} catch (NumberFormatException e1)
{
;
}
if (score != 0.0 && item != null)
{
processingCourse.setEvaluatedPoints(item.getName(), score);
}
}
}
/**
* This class listens for the user to select the actual score button to
* enter an evaluated score for that item.
*
* @author John, Corbin and Rachel
*
*/
private class EstimatedListener extends Thread implements ActionListener
{
private GradeItem item;
private Course processingCourse;
public EstimatedListener(GradeItem item)
{
processingCourse = Course.getInstance();
this.item = item;
}
public void actionPerformed(ActionEvent e)
{
dispose();
try
{
score = Double.valueOf(scoreEntry.getText().trim())
.doubleValue();
} catch (NumberFormatException e1)
{
;
}
if (score != 0.0 && item != null)
{
processingCourse.setEstimatedPoints(item.getName(), score);
}
}
}
}