如何使用JOptionPane.showMessageDialog()
显示多条线。例如,我在下面发布一个例子。现在,在下面的例子中,值a1,b1,c1
必须使用JOptionPane.showMessageDialog()
一个接一个地显示有没有什么办法可以在一个窗口中显示所有的值?因为在下面的例子中,三个窗口将会一个接一个地出现。如何使用单个JOptionPane.showMessageDialog()语句显示多个输出?
class demo()
{
public static void main(String args[])
{
String a=JOptionPane.showInputDialog(null,"Enter a number");
int a1=Integer.parseInt(a);
String b=JOptionPane.showInputDialog(null,"Enter a number");
int b1=Integer.parseInt(b);
int c=a1+b1;
JOptionPane.showMessageDialog(null,a1);
JOptionPane.showMessageDialog(null,b1);
JOptionPane.showmessageDialog(null,c1);
}
}
请问你可以写下它的代码。 – 2012-04-22 04:00:49
@ user1334573:关于你的请求,“你能写出它的代码吗?”这不是在这里完成的事情,也不是你将如何学习。相反,如果您尝试使用我们的建议为其编写代码,您将学到更多。如果你遇到困难,请告诉我们你的努力。 – 2012-04-22 04:02:31
有关第1条建议的基本实现,请参见[本答案](http://stackoverflow.com/a/7861833/418556)。 – 2012-04-22 04:16:08