• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tabbing JTextArea Code Editor

 
Isaac Skelton
Greenhorn
Posts: 5
C++ Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have always wanted to create a simple code editor; nothing fancy, all I want is a TextArea that once the user pushes tab it stays in tab. For example, notepad++ allows the user to tidy his/her script up while notepad (MS) dosn't allow a easy method to do this. I have been researching for a while now and all I could find that was might help me was "setTabSize"

For example,


I hope you understand what im asking for, if not please ask and ill try explain more
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should change the key binding (look it up) for Enter to a) get the whitespace the current line starts with, then perform the default behaviour (add an Enter), then add the whitespace you just got. I'm sure you can solve each of these sub tasks separately; combining them will be easy as well.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic