-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeVoter.java
117 lines (95 loc) · 3.12 KB
/
MakeVoter.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
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
public class MakeVoter extends Dialog {
protected Shell shlCreateAVoter;
private Text text;
private Text text_1;
private Text text_2;
private Text text_3;
private Text text_4;
private Button btnDone;
private Voter v;
/**
* Create the dialog.
* @param parent
* @param style
*/
public MakeVoter(Shell parent, int style) {
super(parent, style);
setText("SWT Dialog");
}
/**
* Open the dialog.
* @return the result
*/
public Voter open() {
createContents();
shlCreateAVoter.open();
shlCreateAVoter.layout();
Display display = getParent().getDisplay();
while (!shlCreateAVoter.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return v;
}
/**
* Create contents of the dialog.
*/
private void createContents() {
shlCreateAVoter = new Shell(getParent(), getStyle());
shlCreateAVoter.setSize(479, 343);
shlCreateAVoter.setText("Create a voter");
text = new Text(shlCreateAVoter, SWT.BORDER);
text.setBounds(10, 37, 300, 24);
Label lblName = new Label(shlCreateAVoter, SWT.NONE);
lblName.setBounds(10, 10, 69, 21);
lblName.setText("Name");
Label lblAge = new Label(shlCreateAVoter, SWT.NONE);
lblAge.setBounds(10, 67, 69, 21);
lblAge.setText("Age");
text_1 = new Text(shlCreateAVoter, SWT.BORDER);
text_1.setBounds(10, 94, 43, 24);
Label lblLocation = new Label(shlCreateAVoter, SWT.NONE);
lblLocation.setBounds(10, 124, 69, 21);
lblLocation.setText("Location");
text_2 = new Text(shlCreateAVoter, SWT.BORDER);
text_2.setBounds(10, 151, 203, 24);
Label lblPhoneNumber = new Label(shlCreateAVoter, SWT.NONE);
lblPhoneNumber.setBounds(10, 181, 170, 24);
lblPhoneNumber.setText("Phone Number");
text_3 = new Text(shlCreateAVoter, SWT.BORDER);
text_3.setBounds(10, 211, 203, 24);
Label lblDateLastContacted = new Label(shlCreateAVoter, SWT.NONE);
lblDateLastContacted.setBounds(10, 241, 258, 24);
lblDateLastContacted.setText("Date Last Contacted (YYYYMMDD)");
text_4 = new Text(shlCreateAVoter, SWT.BORDER);
text_4.setBounds(10, 271, 203, 24);
btnDone = new Button(shlCreateAVoter, SWT.NONE);
btnDone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String name = text.getText();
int age = Integer.parseInt(text_1.getText());
String location = text_2.getText();
String phone = text_3.getText();
String dateLC = text_4.getText();
v = new Voter(name, age, location, phone, dateLC);
shlCreateAVoter.dispose();
}
});
btnDone.setBounds(381, 276, 85, 26);
btnDone.setText("Done");
}
public void shutdown() {
shlCreateAVoter.dispose();
}
}