Search code examples
javajoptionpane

Using JOptionPane


if i was using a JOptionPane message dialog box how would I be able to show an the whole array in the message section such as this little snipit? or would that evenbe possible?

 public void showTheMessage()

{
 JOptionPane.showMessageDialog(null,"These are are all the colors to
          choosfrom,\n"+ arrayOfcolors[the whole array], "Color box");
 }

Solution

  • The easiest thing to do would be to concatenate all the elements of the array into one big string.

    String colors = "";
    for(int i = 0; i < arrayOfColors.length; i++)
        colors += arrayOfColors[i] + " ";