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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Highlighting in JTextArea" Watch "Highlighting in JTextArea" New topic
Author

Highlighting in JTextArea

Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
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

Joined: May 30, 2001
Posts: 328
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,


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Highlighting in JTextArea