简体   繁体   English

JFrame的JTextArea无法保存长粘贴的文本

[英]JFrame's JTextArea Can't Hold Long Pasted Text

I am making a JTextArea so users can paste long amounts of text into it. 我正在制作一个JTextArea,以便用户可以将大量文本粘贴到其中。 However, when that happens, it causes the second image below to occur. 但是,发生这种情况时,它将导致下面的第二张图像出现。 Can anyone help? 有人可以帮忙吗?

粘贴文字之前

粘贴文字后

  1. Wrap the JTextArea in a JScrollPane JTextArea包装在JScrollPane

     JTextArea textArea = new JTextArea(25, 60); JScrolPane scroll = new JScrollPane(textArea); frame.add(scroll); 
  2. Set the line wrap and the wrap style word to true 将换行和换行样式字设置为true

     textArea.setLineWrap(true); textArea.setWrapStyleWord(true); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM