刚学java,不懂,望高手赐教``
import javax.swing.JOptionPane;
public class Test8{

public static void main(String[] args)
{ String output="";
for(int i=1; i<=9;  i++){

output+=i+"  ";

}
output+='\n';
for(int j=9; j<=17;  j++)
{
output+=j+" ";
}
  
  
    System.out.println(output);        JOptionPane.showMessageDialog(null,output,"test",JOptionPane.INFORMATION_MESSAGE);     
}
}请问,为什么命令框里输出的是:1  2  3  4  5  6  7  8  9  
                         9 10 11 12 13 14 15 16 17 而对话框输出的是:   1  2  3  4  5  6  7  8  9
                  9   10  11  12  13  14  15  16  17
??
还有,怎么"\t"在对话框里无效的??加了和没有一样````请大虾解答一下```

解决方案 »

  1.   

    i 和 j 后面加的空格数不同  加了\t 后 数字的间距是一致的。
      

  2.   

    好像是不可以,如果添加一个JTextArea就可以了,不知道为什么
    import javax.swing.JOptionPane;
    import javax.swing.JTextArea;public class Test8 { public   static   void   main(String[]   args) 
    {  String   output= " "; 
    for(int   i=1;   i <=9;     i++){ 

    output+=i+ "\t"; 


    output+= "\n "; 
    for(int   j=9;   j <=17;     j++) 

    output+=j+ "\t"; 

        
        
            System.out.println(output);     
            JTextArea aa = new JTextArea();
            aa.setText(output);
            JOptionPane.showMessageDialog(null,aa, "test",JOptionPane.ERROR_MESSAGE);         
    }
    }
      

  3.   

     还真没有遇见这样的问题,可能是 JOptionPane.showMessageDialog()里的message不识别"\t"吧,(个人想法),
    查了下API也没有什么结果,等待~~~~~~~~~~~ 
      

  4.   

    不识别"\t"你程序错误了。
    '\n'应该改为"\n"
      

  5.   

    回楼上的,'\n'也可以呀``为什么能识别'\n'而不能识别'\t'??
      

  6.   

    看看下面的链接:
    http://www.java2s.com
    希望能帮到楼主