简体   繁体   中英

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

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.

Updated to fix bad link

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM