1
我的ArrayList每次循环时都添加一个String
,但它显示在一条大行上。如何在JOptionPane的新行中显示每个String
,因为它会循环?阵列中的元素列表出现在一个新行上
这里是我的报告方法:
public String report()
{
return(name + "\t" + height + " inches\t" + weight + " pounds\tBMI: "
+ df.format(bmiValue()) + "\t" + bmiStatus());
}
这里是与ArrayList中的代码:
ArrayList a = new ArrayList();
if(JFileChooser.APPROVE_OPTION)
{
File f = choose.getSelectedFile();
Scanner s = new Scanner(new FileInputStream(f));
int l = scanner.nextInt();
for(int i = 0; i < l; i++)
{
int height = s.nextInt();
int weight = s.nextInt();
String name = s.nextLine();
BmiRecord r = new BmiRecord(name, height, weight);
a.add(r.report());
}
confirm = JOptionPane.showConfirmDialog(null, a, "BMI Calc",
JOptionPane.YES_NO_OPTION);