[英]Is there a way to support real \r carriage return without new line break in a JTextArea?
I would like to know if it's possible to support '\\r' (carriage return) without new line break in JTextArea or is this feature supported in any other similar implementations in Java? 我想知道是否有可能在JTextArea中支持'\\ r'(回车)而不换行,还是在Java中任何其他类似的实现中都支持此功能?
Say, after several text appended to a text area, I want this to be appended. 说,将几个文本附加到文本区域后,我希望将其附加。
"Please wait, a download is in progress" “请稍等,下载正在进行中”
After that a download progress status with progress meter character '#' gets appended. 之后,带有进度条字符“#”的下载进度状态将被附加。 eg:
例如:
#\r
##\r
###\r
####\r
#####\r
I would like to inform here that, I'm reading the progress from a buffer character after character. 我想在此通知我,我正在从一个字符接一个字符地读取进度。 I don't want to replace the '\\r' characters I'm reading from the buffer in any way.
我不想以任何方式替换从缓冲区读取的'\\ r'字符。
So, what I would love to see if, the above progress, is displayed in a single line, without having a line break Say, ######### 因此,我很想看看上面的进度是否显示在一行中,而没有换行符说,########
Best regards 最好的祝福
As an alternative to marking progress in the JTextArea
itself, consider decorating it with a JProgressBar
or a variation . 作为一种替代的标志进步
JTextArea
本身,可以考虑用它装饰JProgressBar
或变化 。
Addendum: SwingWorker
is useful for managing lengthy background tasks while displaying interim progress. 附录:
SwingWorker
对于管理冗长的后台任务同时显示临时进度很有用。 In this example , a worker iterates through a SQL ResultSet
and updates a JProgressBar
. 在此示例中 ,工作程序迭代SQL
ResultSet
并更新JProgressBar
。 Note that the GUI's PropertyChangeListener
can update arbitrary components, and the progress bar can be customized . 请注意,GUI的
PropertyChangeListener
可以更新任意组件,并且可以自定义进度条。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.