Finish the WeightView by using a JComboBox.
[Persons_Comparator.git] / src / WeightView.java
CommitLineData
089fcbfc
JB
1import javax.swing.*;
2
d119e60d 3public class WeightView extends JPanel {
6977e614 4 private Weight weightObj;
883508ca 5 private JLabel label;
2bb2aa17 6 private JComboBox<Integer> comboBox;
6977e614 7
b974e749
JB
8 WeightView(Weight weightObj) {
9 setWeightObj(weightObj);
883508ca 10 this.label = new JLabel();
2bb2aa17
JB
11 this.label.setText("Weight (kilograms)");
12 this.comboBox = new JComboBox<>(this.getWeightObj().getValuesArray());
13 if (this.getWeightObj().getWeight() != 0)
14 this.comboBox.setSelectedItem(this.getWeightObj().getWeight());
15 else
16 this.comboBox.setSelectedItem(this.getWeightObj().getDefaultWeight());
883508ca 17 add(label);
2bb2aa17 18 add(comboBox);
089fcbfc
JB
19 }
20
6977e614
JB
21 public Weight getWeightObj() {
22 return weightObj;
23 }
24
25 public void setWeightObj(Weight weightObj) {
26 this.weightObj = weightObj;
27 }
28}