Commit | Line | Data |
---|---|---|
089fcbfc | 1 | import javax.swing.*; |
3d9fdaf4 | 2 | import java.util.Arrays; |
089fcbfc | 3 | |
d119e60d | 4 | public class EyeView extends JPanel { |
6977e614 | 5 | private Eye eyeObj; |
883508ca | 6 | private JLabel label; |
3d9fdaf4 | 7 | private JList colorsList; |
6977e614 | 8 | |
b974e749 JB |
9 | /** |
10 | * @param eyeObj | |
11 | */ | |
12 | EyeView(Eye eyeObj) { | |
13 | setEyeObj(eyeObj); | |
883508ca JB |
14 | this.label = new JLabel(); |
15 | this.label.setText("Eyes color"); | |
3d9fdaf4 JB |
16 | this.colorsList = new JList<>(this.getEyeObj().getColorsList()); |
17 | this.colorsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | |
18 | this.colorsList.setLayoutOrientation(JList.VERTICAL); | |
19 | this.colorsList.setSelectedIndex(Arrays.asList(this.getEyeObj().getColorsList()).indexOf(this.getEyeObj().getStrColor())); | |
883508ca JB |
20 | add(label); |
21 | add(colorsList); | |
089fcbfc JB |
22 | } |
23 | ||
ac6c3ea2 | 24 | /** |
ac6c3ea2 JB |
25 | * @return |
26 | */ | |
6977e614 JB |
27 | public Eye getEyeObj() { |
28 | return eyeObj; | |
29 | } | |
30 | ||
ac6c3ea2 | 31 | /** |
ac6c3ea2 JB |
32 | * @param eyeObj |
33 | */ | |
6977e614 JB |
34 | public void setEyeObj(Eye eyeObj) { |
35 | this.eyeObj = eyeObj; | |
36 | } | |
9b3bfcdd JB |
37 | |
38 | public JList getColorsList() { | |
39 | return colorsList; | |
40 | } | |
6977e614 | 41 | } |