• 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

Buggy text highlighting.

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone have any idea why the following bit of code will change the highlight color of the JTextArea, but won't actually do the highlighting I tell it to?
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this instead:
textArea.setCaretPosition(selStart.intValue());
textArea.moveCaretPosition(selEnd.intValue());
I think the setSelectionStart and setSelectionEnd methods will only work if there is already some text selected.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is wierd because I know that we got it to work on our program a while back. and here is the code that we used.

As you notice we didn't use anything to "select" the text, and I couldn't find it in any of our code, but I know it had worked. Try it and see if it highlights and select all the text in the JTextBox. If not I'll look again for any code that might suggest that.
Mark
p.s. What are you converting? What was the old system written in? Ours was Foxpro 2.6
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the suggestion and code. I'll give it a whirl on Monday morning.


p.s. What are you converting? What was the old system written in? Ours was Foxpro 2.6


I'm actually not doing a conversion, although from the code snippit I posted it must seem that way. I'm just trying to add text highlighting to a prviously written Java module that does data retrieval.
[ May 17, 2002: Message edited by: Matt Senecal ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic