2 import java
.awt
.event
.ItemEvent
;
3 import java
.awt
.event
.ItemListener
;
5 public class OriginView
extends JPanel
implements ItemListener
{
6 private Origin originObj
;
8 private JComboBox
<String
> comboBox
;
9 private JLabel continentLabel
;
11 OriginView(Origin originObj
) {
12 setOriginObj(originObj
);
13 this.label
= new JLabel();
14 this.label
.setText("Origin");
15 this.comboBox
= new JComboBox
<>(this.getOriginObj().getCountriesArray());
16 this.comboBox
.setSelectedItem(this.getOriginObj().getCountry());
17 this.comboBox
.addItemListener(this);
18 this.continentLabel
= new JLabel();
19 this.continentLabel
.setText("(" + this.getOriginObj().getContinent() + ")");
25 public Origin
getOriginObj() {
29 public void setOriginObj(Origin originObj
) {
30 this.originObj
= originObj
;
33 public JComboBox
<String
> getComboBox() {
38 public void itemStateChanged(ItemEvent event
) {
39 if (event
.getStateChange() == ItemEvent
.SELECTED
) {
40 Object item
= event
.getItem();
41 getOriginObj().setContinent(getOriginObj().getContinentFromCountry(item
.toString()));
42 this.continentLabel
.setText("(" + this.getOriginObj().getContinent() + ")");