简体   繁体   中英

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?

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.

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 .

Addendum: SwingWorker is useful for managing lengthy background tasks while displaying interim progress. In this example , a worker iterates through a SQL ResultSet and updates a JProgressBar . Note that the GUI's PropertyChangeListener can update arbitrary components, and the progress bar can be customized .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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