I have a Java class and I want one of its properties to be displayed by a JLabel in a Swing desktop application:
class Item {
private String name;
private Integer quantity;
// getters, setters...
}
class Frame {
Item item = new Item();
...
JLabel label = new JLabel();
label.setText(item.getQuantity().toString());
...
}
How do I get the label to update its text whenever the quantity property changes on the item?