Start the implementation of inputs gathering and the comparator code (still buggy...
[Persons_Comparator.git] / src / WeightView.java
index 3e6d00f668a0270f8f0f9ee5b42e88410e8116f1..2c41f5ec889c2a73430fb3e1f90a391923a390b5 100644 (file)
@@ -1,13 +1,21 @@
 import javax.swing.*;
 
-public class WeightView extends JComponent {
+public class WeightView extends JPanel {
     private Weight weightObj;
-
-    WeightView() {
-    }
+    private JLabel label;
+    private JComboBox<Integer> comboBox;
 
     WeightView(Weight weightObj) {
         setWeightObj(weightObj);
+        this.label = new JLabel();
+        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() {
@@ -17,4 +25,8 @@ public class WeightView extends JComponent {
     public void setWeightObj(Weight weightObj) {
         this.weightObj = weightObj;
     }
+
+    public JComboBox<Integer> getComboBox() {
+        return comboBox;
+    }
 }