How to move an item from one list/arraylist to another list/arraylist?
Here's what I am required to do
ArrayList
. I finally figured out how to add items to an arraylist and display them in a listbox. Now I need to know how to select them and move them to another list/array using a button.
Any ideas?
It will be easier for you to use ListModel
as suggested by MadProgrammer
You can try like this
model = new DefaultListModel<String>();
for(String str : playlist){
model.addElement(str);
}
listPlaylist.setModel(model);
listPlaylist.setSelectedIndex(0);
You can create two models for library and playlist and perform operations
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.