谢了各位
----------------解决方案--------------------------------------------------------
   用toString()方法绝对行,我贴一篇我的程序,其中你说的那种情况就是别人给我添的.你运行一下,参考一下.
   import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class CircleCLS//圆的计算布局第一个。
  {
   JFrame frame;
   JLabel l1,l2,l3;
   JTextField tf1,tf2,tf3;
   JButton b1,b2,b3,b4;
   JPanel p1,p2,p3;
   JTextArea ta;
   final double PI = 3.14;                //PI为常量派。
   public static void main(String[] args)
     {
      CircleCLS cc=new CircleCLS();
      cc.go();
     }
      public void go()
        { 
    
         frame=new JFrame("圆的计算");
         
         l1=new JLabel("请输入圆的半径",l1.LEFT);
         tf1=new JTextField(10);
         b1=new JButton("确定");
         b1.setForeground(Color.white);
         b1.setBackground(Color.black);
         b1.addActionListener(new ActionListener()//开始
           {
            public void actionPerformed(ActionEvent e) 
              {
               Double banjing = Double.parseDouble(tf1.getText());    //
               Double zhouchang = banjing * PI * 2;
               Double mianji = banjing * banjing * PI;
                
               String zhouchang2 = zhouchang.toString();
               String mianji2 = mianji.toString();
               tf3.setText(zhouchang2);
               tf2.setText(mianji2);
              }
           });//结束(从开始到结束为高手指点) 
         b2=new JButton("重置");
         b2.setForeground(Color.black);
         b2.setBackground(Color.white);
         b2.addActionListener(new ActionListener()
           {
            public void actionPerformed(ActionEvent e)
              {
               tf1.setText("");//setText()是修改文本的方法,让它的新参数为空(""),就等于清空了三个文本域。
               tf2.setText("");
               tf3.setText("");
              }
           }); 
         p1=new JPanel();
         p1.add(l1);
         p1.add(tf1);
         p1.add(b1);
         p1.add(b2);
  
         l2=new JLabel("圆的面积");
         tf2=new JTextField(10);
         p2=new JPanel();
         p2.add(l2);
         p2.add(tf2);
         l3=new JLabel("圆的周长");
         tf3=new JTextField(10);
         p3=new JPanel();
         p3.add(l3);
         p3.add(tf3);
         ta=new JTextArea(50,1);
         b3=new JButton("清除");//如果逗号用输入汉字时所用的逗号,会出现"非法的标识符"的错误
         b3.setForeground(Color.black);
         b3.setBackground(Color.white);
         b3.addActionListener(new ActionListener()
           {
            public void actionPerformed(ActionEvent e)
              {
               ta.setText("");
              }
           });
         JScrollPane p4=new JScrollPane(ta,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         tf1.addActionListener(new ActionListener()
           {public void actionPerformed(ActionEvent e)
              {
               String h=tf1.getText();
               ta .append("\n圆的半径:"+h);
              }
           });
         tf2.addActionListener(new ActionListener()
           {
            public void actionPerformed(ActionEvent e)
              {
               String w=tf2.getText();
               ta .append("\n圆的面积:"+w);
              }
           });
         tf3.addActionListener(new ActionListener()
           {
            public void actionPerformed(ActionEvent e)
              {
               String y=tf3.getText();
               ta .append("\n圆的周长:"+y);
              }
           });
           b4=new JButton("拷贝");
           b4.setForeground(Color.black);
           b4.setBackground(Color.white);
           b4.addActionListener(new ActionListener()
           {
            public void actionPerformed(ActionEvent e)
              {
               String h=tf1.getText();
               ta .append("\n圆的半径:"+h);
               String w=tf2.getText();
               ta .append("\n圆的面积:"+w);
               String y=tf3.getText();
               ta .append("\n圆的周长:"+y);
              }
           });
           JPanel p6=new JPanel(); 
           p6.add(b3);
           p6.add(b4);
           JPanel p5=new JPanel();
           p5.setLayout(new GridLayout(1,2));
           p5.add(p4);
           p5.add(p6);
            
            Container cp=frame.getContentPane();
            cp.setLayout(new GridLayout(4,1));
            cp.add(p1);
            cp.add(p2);
            cp.add(p3);
            cp.add(p5);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(450,300);
            frame.setVisible(true);
           }
}
----------------解决方案--------------------------------------------------------
总结一下,就是说在图像用户界面中,使用setText()输出数据类型有两种方法
1)setText(i+"");
2) String j = i.toString();
setText(j);
两种方法有区别吗?
----------------解决方案--------------------------------------------------------
i.toString()是不行的
除非i是Integer对象,而非int
----------------解决方案--------------------------------------------------------