I have an ArrayList and i want to loop through the ArrayList and print the items in the arraylist to JOptionPane.showInput dialogue. But how can i use a looping structure in JOptionPane? The code below shows multiple JOptionPane windows and obiously it will because it is in a loop. Can anyone modify it to show only one JOptionPane window and output all messages in one window.
public void getItemList(){
for (int i=0; i<this.cartItems.size(); i++){
JOptionPane.showInputDialog((i+1) + "." +
this.cartItems.get(i).getName(););
}
}