| Author |
JTextArea little Help
|
Mathew Mintalm
Ranch Hand
Joined: Feb 21, 2010
Posts: 102
|
|
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
Joined: Oct 27, 2005
Posts: 19216
|
|
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.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: JTextArea little Help
|
|
|