设置JavaFX TextArea的选项卡间距/大小可视化 [英] Setting the tab spacing/size visualization for a JavaFX TextArea

查看:416
本文介绍了设置JavaFX TextArea的选项卡间距/大小可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaFX 8,特别是TextArea控件。在该控件中,我可以输入包括制表符字符的自由格式文本。当我输入选项卡时,数据以8个字符为单位。例如。在下面,字符是我输入标签的位置:

I am using JavaFX 8 and specifically the TextArea control. In that control I can enter free form text including "tab" characters. When I enter a tab, the data is spaced in units of 8 characters. For example. In the following, the ! character is where I enter a tab:

1234567890123456789012345678901234567890
!       Data here
ABC!    Data here
!!              Data Here

我的谜题是如何更改视觉的标签间距/大小,以便而不是标签大小为8个字符,只有4个字符。

My puzzle is how to change the tab spacing/sizing for the visual so that instead of the tab size being 8 characters it will only be 4 characters.

为了进一步说明,这是一个实际的屏幕截图,显示了我的文本区域中的标签:

To further illustrate, here is an actual screen shot showing tabs in my text area:

我想将数据保留为包含制表符,而不是用空格替换制表符。

I want to leave the data as containing tab characters and not replace tabs with spaces.

此Stack Exchange问​​题不适用,因为它专门讨论更改标签到空间:

This Stack Exchange question does not apply as it talks exclusively about changing tabs to space:

JavaFX TextArea:如何设置制表宽度

推荐答案

我决定浏览JavaFX的源代码,看看是否我可以找到答案,虽然我不是检查如此大量代码的专家,但我似乎也是发现答案是选项卡大小硬编码为8个字符!!

I decided to grunge through the source code of JavaFX to see if I could find an answer and, although I am not an expert in examining such a large amount of code, I seem to have found that the answer is that the tab size is hard-coded to be 8 characters!!

我发现源文件名为:

com.sun.javafx.text.PrismTextLayout.java

名为 getTabAdvance 的方法返回固定值8。请参阅以下内容:

which has a method called getTabAdvance which returns a fixed value of "8". See the following:

这对我来说是最令人失望的,但事实就是如此。

This is most disappointing to me but it is what it is.

这篇关于设置JavaFX TextArea的选项卡间距/大小可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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