if(e.getStateChange()==ItemEvent.SELECTED) 当选择换行的时候 我想让
textArea 里的文字换行 ,怎么实现??
我用textArea.setLineWrap(true) ; 编译时提示我找不到符号,怎么回事呢 ?怎么解决?谢谢·

解决方案 »

  1.   

    setLineWrap
    public void setLineWrap(boolean wrap)
    Sets the line-wrapping policy of the text area. If set to true the lines will be wrapped if they are too long to fit within the allocated width. If set to false, the lines will always be unwrapped. A PropertyChange event ("lineWrap") is fired when the policy is changed. By default this property is false. Parameters:
    wrap - indicates if lines should be wrapped
    See Also:
    getLineWrap()
    textArea.setLineWrap(true) 绝对没错,再仔细检查一下你程序的其他地方,看一下错在哪里.
      

  2.   

    textArea. 提示的方法中没有 setLineWrap
    这怎么回事呢?
      

  3.   

    最新调试出现的问题 
    我把 TextArea 改为JTextArea  有  setLineWrap()方法
    但是不换行。一行写好多时也没有滚动条。
      
    原来 TextArea 会出现滚动条
      

  4.   

    你的是什么牛X系统啊,我的机器上是没问题的,如JTextArea(10, 10),当输入到达JTextArea边界时,会自动换行的.至于滚动条,因为javax.swing中,滚动条一般都用JScrollPane,JTextArea已经不会自动出现滚动条了,好像TextArea会,得把JTextArea加入到JScrollPane中,才会显示滚动条:
    1. JScrollPane scroller = new JScrollPane(new JTextArea());2. JScrollPane scroller = new JScrollPane();
    scroller.getViewport().setView(new JTextArea());3. 把JScrollPane加入到容器中:frame.add(scroller)或者panel.add(scroller).
      

  5.   

    当输入的字符串里没有‘\s’(空格,回车,制表,等)时,这个字符串在 JTextArea 里不是会换行的。
      

  6.   

    全部源代码太多了 
    就写关键的吧  public void processMsg(String msg){//客户端处理消息
      textArea.append(msg);
      textArea.append("\n");
     }
    这里我想让接收来的信息按照textArea边界大小自动换行。
    这里用是 swt  所以没有  JTextArea.setLineWrap(true)这个方法
    怎么办呢?