X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FWeightView.java;h=2c41f5ec889c2a73430fb3e1f90a391923a390b5;hb=9b3bfcdd95253a04ed12a676ee29a9d777c1e496;hp=1576b62e2e836d77e3433b3c49e32e092ab79bc2;hpb=b974e749af3a4b2df3737b2d361233c704dcc4d8;p=Persons_Comparator.git diff --git a/src/WeightView.java b/src/WeightView.java index 1576b62..2c41f5e 100644 --- a/src/WeightView.java +++ b/src/WeightView.java @@ -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 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() { @@ -18,4 +25,8 @@ public class WeightView extends JComponent { public void setWeightObj(Weight weightObj) { this.weightObj = weightObj; } + + public JComboBox getComboBox() { + return comboBox; + } }