-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScoreEntryPanel.java
52 lines (39 loc) · 1.08 KB
/
ScoreEntryPanel.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
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class ScoreEntryPanel extends JPanel {
private JTextField textField;
private Time time;
/**
* Create the panel.
*/
public ScoreEntryPanel(Main frame) {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
JLabel lblEnterYourName = new JLabel("Enter Your Name:");
add(lblEnterYourName);
Component rigidArea = Box.createRigidArea(new Dimension(20, 200));
add(rigidArea);
textField = new JTextField();
add(textField);
textField.setColumns(10);
textField.setSize(100, 25);
Component rigidArea_1 = Box.createRigidArea(new Dimension(20, 200));
add(rigidArea_1);
JButton btnEnter = new JButton("Enter");
add(btnEnter);
btnEnter.addActionListener(frame);
}
public void setTime(Time t) {
time = t;
}
public Score getScore() {
String name = textField.getText();
textField.setText("");
return new Score(name, time);
}
}