简体   繁体   中英

JEditorPane - make tabs spaces

I'm wondering if there's a way to have tabs convert to spaces in a jeditorpane, much like you'd see when working in an IDE. I don't want to set the tab size . I can already do that easily.

I want to have tabs replaced with their equivalent in spaces. So for example if my tabs are 5 spaces long, I would want all tabs replaced immediately with 5 spaces whenever they are created.

Any ideas?

Add a DocumentFilter to the Document to replaces tabs with spaces as text is inserted into the Document. Read the section from the Swing tutorial on Text Component Features for more information.

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