Setting the tab spacing/size visualization for a JavaFX TextArea

帅比萌擦擦* 提交于 2019-12-11 02:04:21

问题


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

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.

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

JavaFX TextArea: how to set tabulation width


回答1:


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!!

I found the source file called:

com.sun.javafx.text.PrismTextLayout.java

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.



来源:https://stackoverflow.com/questions/27585668/setting-the-tab-spacing-size-visualization-for-a-javafx-textarea

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!