简体   繁体   English

JEdi​​torPane-制作制表符空间

[英]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. 我想知道是否有一种方法可以将制表符转换为jeditorpane中的空格,就像您在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. 因此,例如,如果我的标签页长为5个空格,则在创建时,我希望所有标签页立即用5个空格替换。

Any ideas? 有任何想法吗?

Add a DocumentFilter to the Document to replaces tabs with spaces as text is inserted into the Document. 向文档中添加一个DocumentFilter,以在文本插入到文档中时用空格替换选项卡。 Read the section from the Swing tutorial on Text Component Features for more information. 阅读Swing教程中有关文本组件功能的部分,以获取更多信息。

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

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