aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTextArea little Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea little Help" Watch "JTextArea little Help" New topic
Author

JTextArea little Help

Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

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: 19722
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea little Help