How do I update the quantity of an item without spawning a new object inside my JList

83 Views Asked by At

I want the quanitity shown in (*) to update the value whenver I select an item from the JList and change the quantity of the item without spawning another object in the list.

https://i.stack.imgur.com/ewFEe.png

public void saveList() {
    
    if(fieldValidate()) {
        String name = nameText.getText();
        Integer quantity = Integer.parseInt(quantityText.getText());
        boolean bool = nextDayDelivery.isSelected();
        String type = itemTypeBox.getSelectedItem().toString();
        UUID productID = UUID.fromString(productIDText.getText());
        Product newItemInput = new Product(productID, name, type, quantity, bool);

        data.addElement(newItemInput);
        newItem();
        
    }
    
}

I've been trying for days and I have hit a brick wall now.

1

There are 1 best solutions below

5
pfurbacher On

Updated to fix bad link

A search of the web for "update jlist item edited value" yields Java - Updating JList after changing an object