Remove a warning.
[Persons_Comparator.git] / src / WeightView.java
1 import javax.swing.*;
2
3 public class WeightView extends JPanel {
4 private Weight weightObj;
5 private JLabel label;
6 private JComboBox<Integer> comboBox;
7
8 WeightView(Weight weightObj) {
9 setWeightObj(weightObj);
10 this.label = new JLabel();
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());
17 add(label);
18 add(comboBox);
19 }
20
21 public Weight getWeightObj() {
22 return weightObj;
23 }
24
25 public void setWeightObj(Weight weightObj) {
26 this.weightObj = weightObj;
27 }
28 }