My use case is as follows —
I have a list(ArrayList) of objects, custom data objects.
Now i want to display or represent each of these data objects as a Box containing 3 buttons. So i would have n Boxes for n given data objects in my list.
I want each of these ‘boxes’ to be stacked in a , say, JTable.
Now, whenever a data object is added to the aforementioned list, i want another Box to be created as mentioned before and added to the JTable.
I know this can be accomplished using PropertyChangeListener but i went through some articles online regarding PropertyChangeListener but was not able to get a clear implementable idea.
im new to building UIs and any help with this would be much appreciated.
I would recommend wrapping your
ArrayListwithin aTableModelimplementation, whereby modifications to the list will fire aTableModelEvent.In the example below the underlying List is encapsulated within the model implementation; the only way to modify it is by calling
addItem, which will callfireTableRowsInsertedafter modifying the list. This will result in aTableModelEventbeing fired and subsequently processed by the JTable view onto this model instance.