This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextField & TextArea problem

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
I am working on program that uses a text box to intally show text and another text box that allows the user to enter in the same text. Now if the user enters in somthing different in the input text box to the first text box the progran flags this as an error. This program in a nutshell is a 'Typing Teacher' program.
THE PROBLEM:
The problem is how do I show this error. What I want the text box to do is set the background colour to red BUT ONLY ON THE MISPELT WORD and not the entire text box.I know the alogorithim to do this its just making the text box highlight one word. I would be so, so grateful if some one could shed some light on this problem.
many thanx...
 
Matt Senecal
Ranch Hand
Posts: 255
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are three methods that you'll need to use:
setSelectionStart()
setSelectionEnd()
setSelectionColor()
If you know where the word is in the string of text (and I understand from your post that you do), just set the selection start so that it's just before the word, and the selection end so that it's just after the word. Set the color you want the selection to be (this only needs to be done once for the whole JTextArea/Field), and you're good! .
Originally posted by John Howard:
I am working on program that uses a text box to intally show text and another text box that allows the user to enter in the same text. Now if the user enters in somthing different in the input text box to the first text box the progran flags this as an error. This program in a nutshell is a 'Typing Teacher' program.
THE PROBLEM:
The problem is how do I show this error. What I want the text box to do is set the background colour to red BUT ONLY ON THE MISPELT WORD and not the entire text box.I know the alogorithim to do this its just making the text box highlight one word. I would be so, so grateful if some one could shed some light on this problem.
many thanx...

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic