X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FWeightView.java;h=fd6d68cb40d0e974ca32b226fb3d80cb6611a9a7;hb=c8da8eb79910c7ea33dc2970ebd8d1d1db234a89;hp=239c437556dededfbbaf3839a0dba0b5c528d89b;hpb=883508cad71557d375580ce52a4e093f131405db;p=Persons_Comparator.git diff --git a/src/WeightView.java b/src/WeightView.java index 239c437..fd6d68c 100644 --- a/src/WeightView.java +++ b/src/WeightView.java @@ -1,17 +1,21 @@ import javax.swing.*; -public class WeightView extends JComponent { +public class WeightView extends JPanel { private Weight weightObj; private JLabel label; - - WeightView() { - this.label = new JLabel(); - this.label.setText("Weight"); - add(label); - } + private JComboBox 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() {