| 1 | import javax.swing.*; |
| 2 | |
| 3 | public class EyeView extends JComponent { |
| 4 | private Eye eyeObj; |
| 5 | private JLabel label; |
| 6 | private JList colorsList; |
| 7 | |
| 8 | EyeView() { |
| 9 | setEyeObj(new Eye()); |
| 10 | this.label = new JLabel(); |
| 11 | this.label.setText("Eyes color"); |
| 12 | this.colorsList = new JList(getEyeObj().getColorsList()); |
| 13 | this.colorsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 14 | add(label); |
| 15 | add(colorsList); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * @param eyeObj |
| 20 | */ |
| 21 | EyeView(Eye eyeObj) { |
| 22 | setEyeObj(eyeObj); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @return |
| 27 | */ |
| 28 | public Eye getEyeObj() { |
| 29 | return eyeObj; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @param eyeObj |
| 34 | */ |
| 35 | public void setEyeObj(Eye eyeObj) { |
| 36 | this.eyeObj = eyeObj; |
| 37 | } |
| 38 | } |