• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea little Help

 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have little problem or even two.

So I made little program its like editor and I have JTextArea there, and now I would like to add QUICK USE buttons for example, on press it will add some kind of string on JTextArea but there where is cursor. I dont know how to do it

2. And another question can anyone tell me how can i create something like:

If someone wrote for example string: Hello it will change collor for example on blue something like syntax highlighting.

3. And last question, I made this JTextArea withs scrollings, but I dont know how i can change to scroll IT DOWN, not to right.

Thanks for any help !
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mateusz Mysliwiec wrote:Hello, I have little problem or even two.

So I made little program its like editor and I have JTextArea there, and now I would like to add QUICK USE buttons for example, on press it will add some kind of string on JTextArea but there where is cursor. I dont know how to do it

Check out methods "insert" and getCaretPosition. The latter is inherited from JTextComponent.

2. And another question can anyone tell me how can i create something like:

If someone wrote for example string: Hello it will change collor for example on blue something like syntax highlighting.

JTextArea doesn't support different colors; use JTextPane for that. You may want to check out Ostermiller's syntax highlighing library. I think You can add your own set of keywords by providing a new Lexer implementation. Alternatively, check out this thread. It's also about syntax highlighting.

3. And last question, I made this JTextArea withs scrollings, but I dont know how i can change to scroll IT DOWN, not to right.

It all depends on how you added scrolling. Step 1 would be to add line wrapping to your JTextArea; JTextPane doesn't support this though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic