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() {
public void setWeightObj(Weight weightObj) {
this.weightObj = weightObj;
}
+
+ public JComboBox<Integer> getComboBox() {
+ return comboBox;
+ }
}