Finish the WeightView by using a JComboBox.
[Persons_Comparator.git] / src / WeightView.java
index 1576b62e2e836d77e3433b3c49e32e092ab79bc2..fd6d68cb40d0e974ca32b226fb3d80cb6611a9a7 100644 (file)
@@ -1,14 +1,21 @@
 import javax.swing.*;
 
-public class WeightView extends JComponent {
+public class WeightView extends JPanel {
     private Weight weightObj;
     private JLabel label;
+    private JComboBox<Integer> comboBox;
 
     WeightView(Weight weightObj) {
         setWeightObj(weightObj);
         this.label = new JLabel();
-        this.label.setText("Weight");
+        this.label.setText("Weight (kilograms)");
+        this.comboBox = new JComboBox<>(this.getWeightObj().getValuesArray());
+        if (this.getWeightObj().getWeight() != 0)
+            this.comboBox.setSelectedItem(this.getWeightObj().getWeight());
+        else
+            this.comboBox.setSelectedItem(this.getWeightObj().getDefaultWeight());
         add(label);
+        add(comboBox);
     }
 
     public Weight getWeightObj() {