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) 绝对没错,再仔细检查一下你程序的其他地方,看一下错在哪里.
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) 绝对没错,再仔细检查一下你程序的其他地方,看一下错在哪里.
这怎么回事呢?
我把 TextArea 改为JTextArea 有 setLineWrap()方法
但是不换行。一行写好多时也没有滚动条。
原来 TextArea 会出现滚动条
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).
就写关键的吧 public void processMsg(String msg){//客户端处理消息
textArea.append(msg);
textArea.append("\n");
}
这里我想让接收来的信息按照textArea边界大小自动换行。
这里用是 swt 所以没有 JTextArea.setLineWrap(true)这个方法
怎么办呢?