• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextArea little Help

 
Ranch Hand
Posts: 103
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic