JTextArea Indentation settings

322 Views Asked by At

I am trying to find out how to only move 4 spaces forward in JTextArea, when pressing the 'tab' key on the keyboard. Currently it moves forward 8 spaces.

I've done some reading on Styles in Java and came across setLeftIndent() however this isn't what I need. I have thought about using a key listener so anytime 'tab' is pressed in JTextArea, it only moves forwards by 4 spaces (keybindings).

I would appreciate any advices.

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the setTabSize(...) method of JTextArea:

textArea.setTabSize( 4);