java - JOptionPane Multidimensional Array output -


ok have multidimensional array want display in joptionpane.showmessagedialog. know when using system.out.println, use loop. array size determined user input, therefore have use incrementor.

for example: userinput[k] next usernumber[k] next row userinput[k+1] next usernumber[k+1]

the trouble having using loop, each set 1 @ time in separate windows , not in table in 1 window.

for (int k = 0; k < userinput.length; k++){     joptionpane.showmessagedialog(null, userinput[k]); }  (int k = 0; k < 2; k++){     joptionpane.showmessagedialog(null, usernumber[k]); } 

build output single string.

you can use html tags provide additional formatting

stringbuilder sb = new stringbuilder(64); sb.append("<html><table>"); (int ui = 0; ui = < userinput.length; ui++) {     sb.append("<tr><td>");     sb.append(userinput[ui]);     sb.append("</td>");     (int k = 0; k < 2; k++){         sb.append("<td>");         sb.append(usernumber[k]);         sb.append("</td>");     }     sb.append("</tr>"); } sb.append("</table></html>"); joptionpane.showmessagedialog(null, sb.tostring()); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -