-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathempForm.java
More file actions
153 lines (121 loc) · 4.19 KB
/
empForm.java
File metadata and controls
153 lines (121 loc) · 4.19 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
150
151
152
153
package pack1;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
public class Employee_Form extends JFrame {
private JPanel contentPane;
private JTextField txtName;
private JTextField txtSurname;
private final ButtonGroup btngrpGender = new ButtonGroup();
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Employee_Form frame = new Employee_Form();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Employee_Form() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblname = new JLabel("Name");
lblname.setBounds(21, 11, 46, 14);
contentPane.add(lblname);
txtName = new JTextField();
txtName.setBounds(21, 27, 86, 20);
contentPane.add(txtName);
txtName.setColumns(10);
JLabel lblSurname = new JLabel("Surname");
lblSurname.setBounds(21, 60, 74, 14);
contentPane.add(lblSurname);
txtSurname = new JTextField();
txtSurname.setBounds(21, 75, 86, 20);
contentPane.add(txtSurname);
txtSurname.setColumns(10);
JLabel lblGender = new JLabel("Gender");
lblGender.setBounds(21, 125, 46, 14);
contentPane.add(lblGender);
final JRadioButton rdbtnMale = new JRadioButton("Male");
btngrpGender.add(rdbtnMale);
rdbtnMale.setBounds(18, 146, 109, 23);
contentPane.add(rdbtnMale);
final JRadioButton rdbtnFemale = new JRadioButton("Female");
btngrpGender.add(rdbtnFemale);
rdbtnFemale.setBounds(18, 172, 109, 23);
contentPane.add(rdbtnFemale);
JLabel lblLanguages = new JLabel("Languages");
lblLanguages.setBounds(134, 27, 80, 14);
contentPane.add(lblLanguages);
final JCheckBox chckbxJava = new JCheckBox("Java");
chckbxJava.setBounds(134, 48, 97, 23);
contentPane.add(chckbxJava);
final JCheckBox chckbxCsharp = new JCheckBox("C-Sharp");
chckbxCsharp.setBounds(134, 67, 97, 23);
contentPane.add(chckbxCsharp);
final JCheckBox chckbxPython = new JCheckBox("Python");
chckbxPython.setBounds(134, 86, 97, 23);
contentPane.add(chckbxPython);
final JComboBox comboBox = new JComboBox();
comboBox.setBounds(299, 27, 74, 20);
contentPane.add(comboBox);
String[] cities = {"Istanbul","Ankara","Bursa","Antalya","Izmir"};
DefaultComboBoxModel cities_model = new DefaultComboBoxModel(cities);
comboBox.setModel(cities_model);
JLabel lblAdress = new JLabel("Adress");
lblAdress.setBounds(137, 125, 46, 14);
contentPane.add(lblAdress);
final JTextArea txtAdress = new JTextArea();
txtAdress.setBounds(138, 145, 118, 79);
contentPane.add(txtAdress);
JButton btnSubmit = new JButton("Submit");
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Employee emp1 = new Employee();
emp1.setName(txtName.getText());
emp1.setSurname(txtSurname.getText());
if(rdbtnMale.isSelected()){emp1.setGender("Male");}
if(rdbtnFemale.isSelected()){emp1.setGender("Female");}
String languages="";
if(chckbxJava.isSelected()){languages+="Java ";}
if(chckbxCsharp.isSelected()){languages+="C# ";}
if(chckbxPython.isSelected()){languages+="Python ";}
emp1.setLanguages(languages);
emp1.setAdress(txtAdress.getText());
emp1.setCity(comboBox.getSelectedItem().toString());
emp1.display();
}
});
btnSubmit.setBounds(312, 215, 89, 23);
contentPane.add(btnSubmit);
/*ButtonGroup btngrpGender = new ButtonGroup();
btngrpGender.add(rdbtnMale);
btngrpGender.add(rdbtnFemale);*/
}
}