Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Highlighting in JTextArea

 
Shane Roylance
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a text editor application. Right now its really basic with just a JTextArea, and a JMenuBar in a JDialog. The problem I have is if I highlight some text in the JTextArea, when I click on the menu bar the highlighting dissappears. I know it is a focus problem, but is there anything I can do to fix it or get around it?
Maybe I am going about this all wrong, any ideas??
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just a shot in the dark here.
How about adding a MouseListener to the JTextArea and onMousePressed() try something like this:

I don't have time to test it right now - it's 1am over here in Europe.
Hope that helps,
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic