-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrationForm.java
More file actions
149 lines (144 loc) · 5.31 KB
/
RegistrationForm.java
File metadata and controls
149 lines (144 loc) · 5.31 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package ProjectFMS;
import org.jdatepicker.impl.JDatePanelImpl;
import org.jdatepicker.impl.JDatePickerImpl;
import org.jdatepicker.impl.UtilDateModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.*;
import java.util.*;
public class RegistrationForm extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
public JDatePickerImpl datePicker;
private String department,type;
private JLabel l2, l3, l4, l5,l6, l7, l8;
private JTextField Name, Username, Address;
private JButton Submit, Clear;
private JPasswordField Password;
private JLabel lblRegistration,lblNewLabel;
private JComboBox jcb;
public RegistrationForm() {
this.setVisible(true);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
l2 = new JLabel("Name:");
l3 = new JLabel("Username:");
l4 = new JLabel("Password:");
l5 = new JLabel("DOB:");
l6 = new JLabel("Address:");
l7 = new JLabel("Department:");
l8 = new JLabel("Type:");
jcb = new JComboBox();
Name = new JTextField();
Username = new JTextField();
Password = new JPasswordField();
Address = new JTextField();
Submit = new JButton("Submit");
jcb.addItem("Electricity");
jcb.addItem("HVAC");
jcb.addItem("Audio/Video");
jcb.addItem("HouseKeeping");
jcb.addItem("Security");
Submit.addActionListener (new ActionListener(){
public void actionPerformed(ActionEvent e)
{
if (Name.getText().isEmpty()||Username.getText().isEmpty()||Address.getText().isEmpty())
lblNewLabel.setText("All fields are required");
else
{
File myFile = new File("Registrations.csv");
try
{
FileWriter fileWriter = new FileWriter(myFile,true);
StringBuilder string1=new StringBuilder();
string1.append("\r\n"+Username.getText()+","+String.valueOf(Password.getPassword())+","+Name.getText()+","+datePicker.getJFormattedTextField().getText()+","+Address.getText()+","+"department"+","+type); fileWriter.write(string1.toString());
System.out.println(string1);
fileWriter.close();
dispose();
}
catch(IOException ex){}
}
}
});
Clear = new JButton("Clear");
Clear.addActionListener (new ActionListener(){
public void actionPerformed(ActionEvent e)
{
RegistrationForm r=new RegistrationForm();
dispose();
}
});
l2.setBounds(386, 70, 200, 30);
l3.setBounds(386, 111, 200, 30);
l4.setBounds(386, 152, 200, 30);
l5.setBounds(386, 193, 200, 30);
UtilDateModel model = new UtilDateModel();
Properties p = new Properties();
p.put("text.today", "Today");
p.put("text.month", "Month");
p.put("text.year", "Year");
JDatePanelImpl datePanel = new JDatePanelImpl(model,p);
datePicker = new JDatePickerImpl(datePanel,new DateLabelFormatter());
l7.setBounds(386, 272, 200, 30);
jcb.setBounds(618,272,200,30);
l8.setBounds(386, 313, 200, 30);
Name.setBounds(618, 70, 200, 30);
Username.setBounds(618, 111, 200, 30);
Password.setBounds(618, 152, 200, 30);
datePicker.setBounds(618, 193, 200, 30);
Address.setBounds(618, 234, 200, 30);
Submit.setBounds(568, 417, 100, 30);
Clear.setBounds(678, 417, 100, 30);
getContentPane().add(l2);
getContentPane().add(Name);
getContentPane().add(l3);
getContentPane().add(Username);
getContentPane().add(l4);
getContentPane().add(Password);
getContentPane().add(l5);
getContentPane().add(datePicker);
getContentPane().add(l6);
getContentPane().add(Address);
getContentPane().add(l7);
getContentPane().add(l8);
getContentPane().add(Submit);
getContentPane().add(Clear);
getContentPane().add(jcb);
JButton btnStaff = new JButton("Staff");
JButton btnSupervisor = new JButton("Supervisor");
btnStaff.setBounds(618, 314, 89, 23);
btnStaff.addActionListener (new ActionListener(){
public void actionPerformed(ActionEvent e)
{
type="Staff";
btnStaff.setBackground(Color.CYAN);
btnSupervisor.setEnabled(false);
}
});
contentPane.add(btnStaff);
btnSupervisor.setBounds(729, 314, 89, 23);
btnSupervisor.addActionListener (new ActionListener(){
public void actionPerformed(ActionEvent e)
{
type="Supervisor";
btnSupervisor.setBackground(Color.CYAN);
btnStaff.setEnabled(false);
}
});
contentPane.add(btnSupervisor);
lblRegistration = new JLabel("Registration");
lblRegistration.setFont(new Font("Serif", Font.PLAIN, 38));
lblRegistration.setBounds(575, 11, 212, 48);
contentPane.add(lblRegistration);
lblNewLabel = new JLabel("");
lblNewLabel.setBounds(661, 496, 46, 14);
contentPane.add(lblNewLabel);
}
}