Change the EyeView for a JComboList, store the color string inside the Eye class...
[Persons_Comparator.git] / src / EyeView.java
1 import javax.swing.*;
2
3 public class EyeView extends JComponent {
4 private Eye eyeObj;
5 private JLabel label;
6 private JComboBox colorsList;
7
8 /**
9 * @param eyeObj
10 */
11 EyeView(Eye eyeObj) {
12 setEyeObj(eyeObj);
13 this.label = new JLabel();
14 this.label.setText("Eyes color");
15 this.colorsList = new JComboBox<>(this.getEyeObj().getColorsList());
16 if (this.getEyeObj().getStrColor() != null)
17 this.colorsList.setSelectedItem(this.getEyeObj().getStrColor());
18 add(label);
19 add(colorsList);
20 }
21
22 /**
23 * @return
24 */
25 public Eye getEyeObj() {
26 return eyeObj;
27 }
28
29 /**
30 * @param eyeObj
31 */
32 public void setEyeObj(Eye eyeObj) {
33 this.eyeObj = eyeObj;
34 }
35 }