Javax.swing.JOptionPane 无法打印出 PrintStream 变量

Javax.swing.JOptionPane can't print out PrintStream variable

我不知道如何在joptionpane 中打印出一个字符串和一个变量。可能吗?如果不是那我该怎么办?

String peopleadded = JOptionPane.showInputDialog("How many people do you     want to add");
    int peopleadded1 = Integer.parseInt(peopleadded);
    String[][] People = new String[peopleadded1][2];
    System.out.println("put your name in the array");
    People[0][0] = JOptionPane.showInputDialog("Put your Name");
    System.out.println("put your password in the array");
    People[0][1] = JOptionPane.showInputDialog("Put your Password");
    PrintStream person = System.out.printf("Your array num [%s] and name is %s and your password is %s", 0, People[0][0], People[0][1]);
    JOptionPane.showMessageDialog(null, person);

使用"Text"+varName+"moretext"等(不用打印流,直接在选项面板中)

编辑: 你可以使用这个:

int peopleCount = Integer.parseInt(JOptionPane.showInputDialog(null,"How many people do you want to add?", "Add People", JOptionPane.QUESTION_MESSAGE));
String[][] addPeople = new String[peopleCount][2];
for (int i=0; i<peopleCount; i++) {
    addPeople[i][0] = JOptionPane.showInputDialog(null,"Person "+(i+1)+"\'s name:","Person "+(i+1),JOptionPane.PLAIN_MESSAGE);
    addPeople[i][1] = JOptionPane.showInputDialog(null,"Person "+(i+1)+"\'s password:","Person "+(i+1),JOptionPane.PLAIN_MESSAGE);
}
String people="";
for (int i=0; i<peopleCount; i++)
    people+="Person "+(i+1)+":\n     Name: "+addPeople[i][0]+"\n     Password: "+addPeople[i][1]+"\n";
JOptionPane.showMessageDialog(null,people,"People added",JOptionPane.INFORMATION_MESSAGE);

或者,如果您想在单独的对话框中显示每个人:

int peopleCount = Integer.parseInt(JOptionPane.showInputDialog(null,"How many people do you want to add?", "Add People", JOptionPane.QUESTION_MESSAGE));
String[][] addPeople = new String[peopleCount][2];
for (int i=0; i<peopleCount; i++) {
    addPeople[i][0] = JOptionPane.showInputDialog(null,"Person "+(i+1)+"\'s name:","Person "+(i+1),JOptionPane.PLAIN_MESSAGE);
    addPeople[i][1] = JOptionPane.showInputDialog(null,"Person "+(i+1)+"\'s password:","Person "+(i+1),JOptionPane.PLAIN_MESSAGE);
}
for (int i=0; i<peopleCount; i++)
    JOptionPane.showMessageDialog(null,"Person "+(i+1)+":\n  Name: "+addPeople[i][0]+"\n  Password: "+addPeople[i][1],"Person "+(i+1),JOptionPane.INFORMATION_MESSAGE);