I have two JLists.
List A has these elements:
- 1
- two
- 78
- item4
List B that is for now empty.
My frame has these two list and a button Verify. Once I click on the button, the selected item of List A gets verified whether it is an integer. If so, the selected item has to be transfered to List B and removed from List A.
What I did so far is when clicking on the button, the item get copied but once I selected another item the previous one get replaced with the new item which I don’t want.
How can transfer (append) the item to the other list and remove it from the first one, this way I have got finally the list with all the items without being replaced by the new items.
Use a
DefaultListModel.Now, the same for your list B.
If you want to add items to your second list, just add them to the
DefaultListModeldlmB. This means you have to keep a reference todlmBin your working class, this way you can add elements to it inside the ActionListener of your button.