JTextArea:如何用文字而不是字符来包装文本? [英] JTextArea: how to wrap text by words, not characters?

查看:153
本文介绍了JTextArea:如何用文字而不是字符来包装文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想避免这样的输出:

这是一些文字t

帽子正在被包裹起来

d by characters,sp

litting words in ha

lf

Here is some text t
hat is being wrappe
d by characters, sp
litting words in ha
lf

我正在使用带有setLineWrap(true)的JTextArea。但是我怎么能把它包起来呢? (有没有办法让它只在有空格或东西时换行?)

I am using a JTextArea, with setLineWrap(true). How can I make it wrap words, though? (Is there a way to make it only wrap when there is a space or something?)

推荐答案

JTextArea.setWrapStyleWord(true)

这篇关于JTextArea:如何用文字而不是字符来包装文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆