private TextField tf;
tf=new TextField(30);
String s="The mouse entered";
tf.setText(s);

解决方案 »

  1.   

    new 一个 TextField 对象 就是文本框了
    参数 是长度吧
      

  2.   

    JTextField
    public JTextField(int columns)
    Constructs a new empty TextField with the specified number of columns. A default model is created and the initial string is set to null. Parameters:
    columns - the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation