I have an array list with several objects in it, and these are shown in a JList panel. I want to select an object and when I press a button it will add the selected item to another ArrayList. That one will also be shown on a second JList.
The code below shows the work I have done so far:
import java.util.ArrayList;
 /**
 * 
 * ArrayList for the class, will hold all food items
 * @author Jonathan
 * @version 1.0
 *
 */
public class RestaurantArrayList extends MenuItem
{  
    public RestaurantArrayList(String nameFood, String typeFood, float foodPrice, int caloryCount) {
        super(nameFood, typeFood, foodPrice, caloryCount);
    }
    public static final ArrayList<MenuItem> items;
    static {
        items = new ArrayList<>();
        items.add(new MenuItem("Coca Cola", "Drink", 3.00f, 38));
        items.add(new MenuItem("Fanta Orange", "Drink", 3.00f, 31 ));
        items.add(new MenuItem("Glass of Red Wine", "Drink", 5.00f, 85));
        items.add(new MenuItem("Glass of White Wine", "Drink", 5.00f, 82));
        items.add(new MenuItem("Carling", "Drink", 3.50f, 189));
        items.add(new MenuItem("Fosters", "Drink", 3.50f, 378));
        items.add(new MenuItem("Water", "Drink", 0.00f, 0));
        items.add(new MenuItem("Breads", "Starter", 5.00f, 150));
        items.add(new MenuItem("Cold Meat", "Starter", 5.00f, 150));
        items.add(new MenuItem("Potato Skins and Barbeque Sauce", "Starter", 5.00f, 500));
        items.add(new MenuItem("Cold Meat", "Starter", 5.00f, 400));
        items.add(new MenuItem("Garlic Bread and Cheese", "Starter", 4.50f, 450));
        items.add(new MenuItem("Steak", "Main", 13.50f, 750));
        items.add(new MenuItem("Cheese and Bacon Burger", "Main", 8.00f, 850));
        items.add(new MenuItem("Spaghetti Cabonara", "Main", 7.00f, 675));
        items.add(new MenuItem("Steak", "Main", 13.50f, 378));
        items.add(new MenuItem("Seafood Paella", "Main", 10.00f, 850));
    }
}
Here is the first ArrayList with all my items added into the Array.
JButton button = new JButton(">>");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });
        button.setBounds(333, 180, 59, 25);
        contentPane.add(button);
Here is the button I need to work with an action listener. But I'm not sure what to put into the action listener. I also haven't got the second array yet, because I don't know how to set it up, so I can dynamically add objects into it.
If I am going about this in a weird way then I'm open to suggestions, remember I'm new so I might be going about it in a long winded method.
 
     
     
    